Powershell:使用MTOM消息编码消耗WCF服务时出错
我目前正在探索powershell功能,但我遇到了一个我无法解决的问题。任何快速提示将不胜感激=)
我的目标:
从powershell v2.0调用WCF服务(使用MTOM消息编码配置)中的方法(希望使用new-webserviceproxy cmdlet)
我的问题:
当消息编码设置为Mtom时,new-webserviceproxy cmdlet无法正确解析服务的响应。我收到以下错误:
电源外壳:
$proxyObject = New-WebServiceProxy -URI "http://myserver.com/AccessService.svc?wsdl"
$proxyObject.TestWebServiceConnection()
使用“0”参数调用“TestWebServiceConnection”的异常:“客户端发现响应内容类型为'multipart / related; type =”application / xop + xml“; start =”&lthttp://tempuri.org/0>“;边界=“UUID:
4001d529-32b9-4560-9f4b-550c35c67b03 + id = 4“; start-info =”text / xml“',但预期'text / xml'。
请求失败,并显示错误消息:
-
--uuid:4001d529-32b9-4560-9f4b-550c35c67b03 + ID = 4
Content-ID:&lthttp://tempuri.org/0>
内容传输编码:8位
Content-Type:application / xop + xml; charset = utf-8; type =“text / xml”
&lts:Envelope xmlns:s =“http://schemas.xmlsoap.org/soap/envelope/”&gt
&LTS:车身与GT
&ltTestWebServiceConnectionResponse xmlns =“http://myserver.com/”&gt
&ltTestWebServiceConnectionResult&gtsuccess&LT / TestWebServiceConnectionResult&GT
&LT / TestWebServiceConnectionResponse&GT
&LT /秒:车身与GT
&LT /秒:信封&GT
--uuid:4001d529-32b9-4560-9f4b-550c35c67b03 + ID = 4--
- “。
在线:1字符:38
+ $ proxyObject.TestWebServiceConnection&lt< lt< lt>>错误.txt
+ CategoryInfo:NotSpecified:(:) [],MethodInvocationException
+ FullyQualifiedErrorId:DotNetMethodException
注意我可以通过其他客户端甚至Microsoft提供的wcfclient工具来使用WCF服务。您可以看到TestWebServiceConnectionResult返回成功,但似乎代理对象无法解析响应。
行为:
ltserviceBehaviors && GT
&ltbehavior name =“MyServiceBehavior”&gt
&ltserviceThrottling maxConcurrentCalls =“100”maxConcurrentSessions =“100”/&gt
&ltserviceMetadata httpGetEnabled =“true”httpsGetEnabled =“false”/&gt
&ltserviceDebug includeExceptionDetailInFaults =“false”/&gt
&LT /行为&GT
&LT / serviceBehaviors&GT
绑定(我已经排除了超时值/读者配额和消息大小,因为它们的值的排列似乎与我的问题无关):
ltbasicHttpBinding && GT
&ltbinding name =“basicHttpEndpointBinding”messageEncoding =“Mtom”&gt
&ltsecurity mode =“无”&gt
&lttransport clientCredentialType =“None”/&gt
&LT /安全&GT
&LT / basicHttpBinding的&GT
服务
&ltservice behaviorConfiguration =“MyServiceBehavior”name =“MyService.AccessService”&gt
&ltendpoint address =“”binding =“basicHttpBinding”bindingConfiguration =“basicHttpEndpointBinding”name =“basicHttpEndpointAccessService”bindingNamespace =“http://myserver.com/”contract =“MyService.IAccessService”/&gt
&ltendpoint address =“mex”binding =“basicHttpBinding”bindingConfiguration =“basicHttpEndpointBinding”name =“mexEndpointAccess”contract =“IMetadataExchange”/&gt
&LT /服务&GT
没有找到相关结果
已邀请:
2 个回复
豪抱怒掳
cmdlet;它看起来不像cmdlet支持它。我的解决方法涉及对wsdl运行
,然后使用
将类编译成dll。然后,我将生成的程序集加载到powershell运行时,然后手动配置端点和代理类的绑定: 从wsdl生成.cs文件:
注意
和
可能不在你的powershell的路径中。您可以将其添加到PATH或使用完整路径。
可以在你的
中找到。
位于
文件夹中 生成.cs文件后,需要将其编译为dll:
将已编译的dll加载到powershell中:
在powershell中实例化代理客户端:
骨乏唯瓜