繁体   English   中英

无法将 WCF 服务请求作为 SOAP+XML 发送

[英]Can't send WCF Service request as SOAP+XML

使用 Visual Studio 2010,我开发了一个托管在 web 应用程序上的 WCF 服务,供第三方使用。 他们告诉我他们不能调用它。 为了进行测试,他们将我重定向到 Altova XmlSpy 并指出,在创建新的 SOAP 请求时,如果他们在“更改 SOAP 请求参数”菜单项中选择“作为 SOAP+XML (SOAP 1.2) 发送”检查,他们会得到以下两个警报对话框:

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 服务,从没有任何理论知识开始(但我想每个人都这样做:-)),所以我什至不知道在哪里解决这个问题。 问题可能出在绑定上吗? 我使用 Add/New Item/WCF Service 创建了服务并保留了所有默认选项,因此它应该是 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/")]

属性和实现它的 class 具有

[ServiceBehavior(IncludeExceptionDetailInFaults = true, Namespace = "http://www.archinet.it/HRSuite/Processi/")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

属性

谢谢

编辑:第三方正在使用 Oracle SOA 中间件

BasicHttpBinding使用 SOAP 1.1,因此您无法使用此绑定将 SOAP 1.2 中的请求发送到端点。 HTTP 状态代码 415 表示不受支持的媒体类型,这也暗示了这一点,因为 SOAP 1.1 使用文本/xml 内容类型,而 SOAP 1.soap+xml 内容类型使用应用程序内容

如果您希望 BasicHttpBinding 与 SOAP 1.2 等效,而 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 中间件中使用您的服务需要几分钟以上的时间。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM