現在、powershell の機能を調査していますが、解決できない問題に遭遇しました。簡単なヒントをいただければ幸いです =)
私の目標: powershell v2.0 から (できれば new-webserviceproxy コマンドレットを使用して) WCF サービス (MTOM メッセージ エンコーディングで構成) からメソッドを呼び出す
私の問題: メッセージ エンコーディングが Mtom に設定されている場合、new-webserviceproxy コマンドレットはサービスの応答を正しく解析できません。次のエラーが表示されます。
パワーシェル:
$proxyObject = New-WebServiceProxy -URI "http://myserver.com/AccessService.svc?wsdl"
$proxyObject.TestWebServiceConnection()
"0" 個の引数を指定して "TestWebServiceConnection" を呼び出し中に例外が発生しました: "クライアントが 'multipart/related; type="application/xop+xml" の応答コンテンツ タイプを検出しました;start="<http://tempuri.org/0> ";boundary="uuid:
4001d529-32b9-4560-9f4b-550c35c67b03+id=4";start-info="text/xml"', but expected 'text/xml'.
要求はエラー メッセージで失敗しました:
- -
--uuid:4001d529-32b9-4560-9f4b-550c35c67b03+id=4
Content-ID: <http://tempuri.org/0>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml; charset=utf-8;type="text/xml"
<s:封筒 xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:本文>
< TestWebServiceConnectionResponse xmlns="http://myserver.com/">
<TestWebServiceConnectionResult>成功</TestWebServiceConnectionResult>
</TestWebServiceConnectionResponse>
</s:Body>
</s:Envelope>
--uuid:4001d529-32b9-4560-9f4b-550c35c67b03+id=4--
--."
行: 1 文字:38
+ $proxyObject.TestWebServiceConnection <<<< () >> error.txt
+ CategoryInfo : NotSpecified: (:) []、MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
他のクライアントや Microsoft が提供する wcfclient ツールを介して WCF サービスを利用できることに注意してください。TestWebServiceConnectionResultがsuccessを返したことがわかりますが、プロキシ オブジェクトが応答を解析できたようには見えません。
動作:
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="100"/>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</振る舞い>
</serviceBehaviors>
バインディング(タイムアウト値/リーダー クォータとメッセージ サイズは、それらの値の順列が私の問題に関連していないように見えるため、除外しました):
<basicHttpBinding>
<binding name="basicHttpEndpointBinding" messageEncoding="Mtom">
<security mode="None">
<transport clientCredentialType="None"/>
</security>
</basicHttpBinding>
サービス
<service behaviorConfiguration="MyServiceBehavior" name="MyService.AccessService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpEndpointBinding" name="basicHttpEndpointAccessService" bindingNamespace="http://myserver.com/" contract= "MyService.IAccessService"/>
<endpoint address="mex" binding="basicHttpBinding" bindingConfiguration="basicHttpEndpointBinding" name="mexEndpointAccess" contract="IMetadataExchange"/>
</service>