如何解决无法将WCF服务请求发送为SOAP + XML
| 我使用Visual Studio 2010开发了WCF服务,该服务托管在Web应用程序上,供第三方使用。他们告诉我他们不能调用它。为了进行测试,他们将我重定向到Altova XmlSpy,并指出,在创建新的SOAP请求时,如果他们选择\“以SOAP + XML发送(SOAP 1.2)发送”,请在\“更改SOAP请求参数\”菜单中进行检查项,它们将显示以下两个警报对话框:HTTP error: could not POST file ‘/TurniArc/WebServices/Processi.svc’ on server ’10.51.0.108’ (415)
Error sending the soap data to ‘http://10.51.0.108/TurniArc/WebServices/Processi.svc’ HTTP error: could not POST file ‘/TurniArc/WebServices/Processi.svc’ on server ’10.51.0.108’ (415)
我确实证实了这一点。
取消选中该选项,将根据需要提交请求。而且,我一直使用内部测试的软件soapUI调用我的Web服务从来没有任何问题。
这是我创建的第一个Web Service,开始时没有任何理论知识(但我想每个人都:-)),所以我什至不知道在哪里解决此问题。问题可能出在绑定上吗?我使用“添加/新建项/ WCF服务”创建了该服务,并保留了所有默认选项,因此该名称应为BasicHttpBinding
这是我的web.config的serviceModel部分
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name=\"\">
<serviceMetadata httpGetEnabled=\"true\" />
<serviceDebug includeExceptionDetailInFaults=\"true\" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled=\"true\" aspNetCompatibilityEnabled=\"true\"/>
<!--other bindings related to proxies to other services I\'m invoking -->
</system.serviceModel>
我的界面只有
[ServiceContract(Namespace=\"http://www.archinet.it/HRSuite/Processi/\")]
属性和实现它的类具有
[ServiceBehavior(IncludeExceptionDetailInFaults = true,Namespace = \"http://www.archinet.it/HRSuite/Processi/\")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
属性
谢谢
编辑:第三方正在使用Oracle SOA中间件
解决方法
“ 4”使用SOAP 1.1,因此您不能使用此绑定将SOAP 1.2中的请求发送到端点。 HTTP状态代码415表示不受支持的媒体类型,这也暗示了这一点,因为SOAP 1.1使用text / xml内容类型,而SOAP 1.2使用application / soap + xml内容类型。
如果要与SOAP 1.2等效的BasicHttpBinding,而WsHttpBinding中不包含任何其他WS- *,则需要创建自定义绑定。最简单的版本如下所示:
<bindings>
<customBinding>
<binding name=\"soap12\">
<textMessageEncoding messageVersion=\"Soap12\" />
<httpTransport />
</binding>
</customBinding>
</bindings>
然后,您必须手动定义服务的端点(当前使用默认端点):
<services>
<service name=\"YourNamespace.YourServiceClass\">
<endpoint address=\"\" binding=\"customBinding\" bindingConfiguration=\"soap12\"
contract=\"YourNamespace.YourServiceContractInterface\" />
<endpoint address=\"mex\" binding=\"mexHttpBinding\" contract=\"IMetadataExchange\" />
</service>
</services>
无论如何,我几乎不认为重新配置SOAP版本以消耗Oracle SOA中间件中的服务需要花费几分钟以上的时间。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。