我在IIS下托管了一个WCF服务,位于负载均衡器后面。在LB上卸载SSL,然后在普通HTTP中调用该服务。
我得到了服务的REST端点,但我似乎无法使SOAP端点显示wsdl页面。调用https://domain/Service.svc/soap?wsdl
时,浏览器会收到400 Bar Request响应。我也检查了svclog,错误是There is a problem with the XML that was received from the network. See inner exception for more details.
,这意味着它希望我执行POST
而不是GET
并发送XML。
来自配置的片段:
<bindings>
<basicHttpBinding>
<binding name="basicBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="Transport"></security>
<readerQuotas maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="webBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="Transport"></security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="MyServiceBehavior" name="Namespace.Service">
<endpoint address="" behaviorConfiguration="MyRESTBehavior" binding="webHttpBinding" bindingConfiguration="webBinding" name="REST" contract="Namespace.IService" />
<endpoint address="https://domain/Service.svc/soap" binding="basicHttpBinding" bindingConfiguration="basicBinding" name="SOAP" contract="Namespace.IService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="6553600" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="MyRESTBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
我也尝试过使用wsHttpBinding,但唯一不同的结果是获得了401
。任何指示赞赏。
答案 0 :(得分:0)
我不相信你可以使用basicHttpBinding端点的绝对地址。试试这个:
<endpoint address="soap" binding="basicHttpBinding" bindingConfiguration=...
要访问WSDL,您的URL应如下所示:“https://domain/soap/Service.svc?wsdl”。使用IIS&amp; WCF,您无法覆盖虚拟目录的URL。端点地址值应该相对于网站URL。
答案 1 :(得分:0)
我找到了。我之前删除了httpsGetUrl
中的serviceMetadata
属性,因为我收到有关发布服务两次的错误。我现在认为错误可能是由于输入错误而我不应该删除httpsGetUrl
。将behaviors
部分更改为下面的部分已解决了我的问题:
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" httpsGetUrl="https://domain/Service.svc/soap" />
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="6553600" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="MyRESTBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>