0

ここでMSDN が提供する WCF サンプルを使用して、WCFの使用感をつかもうとしています。残念ながら、最も基本的な WCF サンプルでさえ実行できませんでした。これは、(インストール手順に従って) "C:\WF_WCF_Samples\WCF\Basic\GettingStarted" にある可能性があります。WCF インストーラーによって生成されたサンプル コードは変更していません。

サービスを実行すると、次のエラーが表示されます。

    An unhandled exception of type 'System.ServiceModel.ProtocolException' occurred in mscorlib.dll

Additional information: The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<!DOCTYPE html>

<html>

    <head>

        <title>Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.</title>

        <meta name="viewport" content="width=device-width" />

        <style>

         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 

         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}

         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}

         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }

         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }

         pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}

         .marker {font-weight: bold; color: black;text-decoration: none;}

         .version {color: gray;}

         .error {margin-bottom: 10px;}

         .expandable {'.

これは、正しく解釈すると、サービスが xml 形式のデータではなく、html 形式のコンテンツを返していることを意味します。

インターネットで検索したところ、サービスをホストしているユーザー「ネットワーク サービス」が非常に最小限の権限しか持っていないという事実に問題が関連している可能性があるというスタック オーバーフロー スレッドが見つかりました (現在はリンクが見つかりません)。 「C:\inetpub\wwwroot\」フォルダーを変更することはできません。アクセス許可を変更しようとすると、次のエラーが発生しました。

An error occured while applying security information to:

C:\inetpub\wwwroot\msmq

Failed to enumerate objects in the container. Access is denied.

また、次の方法で開発者コマンドプロンプトから(見つけたコマンドを使用して)権限を変更しようとしました:

C:\Program Files (x86)\Microsoft Visual Studio 11.0>icacls %systemdrive%\inetpub
 /grant %userdomain%\%username%:(OI)(CI)(F) /grant %userdomain%\%username%:F
C:\inetpub: Access is denied.
Successfully processed 0 files; Failed processing 1 files

C:\Program Files (x86)\Microsoft Visual Studio 11.0>

ただし、上記が示すように、それは明らかに機能しませんでした。

この関連するスタック オーバーフローの質問で提供されている解決策も試しましたが、役に立ちませんでした。

サンプルを実行できるようにしたいと考えています (将来的には、自分のサービスも実行できるようにしたいと考えています)。それを可能にするには、どのような手順を踏む必要がありますか? 私は WCF やサーバー開発の経験がほとんどないため、サービスのセットアップで「些細な」間違いを犯した可能性は十分にあります。

最後に、何か影響がある場合は、Windows 8 Pro で VS 2012 を使用しています。サンプルをデバッグ モードで実行しました。

必要に応じて、サービスからサンプル コードを投稿できます。

4

2 に答える 2