WCF服务多个端点配置不起作用

时间:2022-02-13 16:47:25

WCF服务多个端点配置不起作用As per microsoft suggest, for soap1.1, soap1.2, rest based i.e. json, xml, it can be configure from web config. So the web config will decide service based on address. But not working properly. Please suggest.

根据微软建议,对于soap1.1,soap1.2,基于休息,即json,xml,它可以从web配置进行配置。因此,Web配置将根据地址决定服务。但是不能正常工作。请建议。

<appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>

<system.web>
   <compilation debug="true" targetFramework="4.5.1"/>
   <httpRuntime targetFramework="4.5"/>
 </system.web>

 <system.serviceModel>
   <services>
      <service name="PaymentService.Service1">
         <endpoint address="soapbasic" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" behaviorConfiguration="SampleServiceBehavior" contract="PaymentService.IService1" />
         <endpoint address="json" binding="webHttpBinding" bindingConfiguration="webHttpBindingJson" behaviorConfiguration="jsonBehavior" contract="PaymentService.IService1"/>
         <endpoint address="xml" binding="webHttpBinding" bindingConfiguration="webHttpBindingXml" behaviorConfiguration="poxBehavior" contract="PaymentService.IService1"/>
         <endpoint address="soapWs" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="PaymentService.IService1"/>
         <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="SampleServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="True" />
      <serviceCredentials useIdentityConfiguration="false" />
    </behavior>

    <behavior name="SampleServiceBehaviorSOAP">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>

  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="jsonBehavior">
      <enableWebScript/>
    </behavior>
    <behavior name="poxBehavior">
      <enableWebScript/>
    </behavior>
  </endpointBehaviors>
</behaviors>
<bindings>
  <basicHttpBinding>
    <binding name="basicHttpBinding">
      <security mode="None" />
    </binding>
  </basicHttpBinding>
  <webHttpBinding>
    <binding name="webHttpBindingJson">
      <security mode="None"/>
    </binding>
    <binding name="webHttpBindingXml">
      <security mode="None"/>
    </binding>
  </webHttpBinding>
  <wsHttpBinding>
    <binding name="wsHttpBinding">
      <security mode="None"/>
    </binding>
  </wsHttpBinding>
</bindings>   

 </system.serviceModel>

</configuration>

3 个解决方案

#1


0  

By adding behaviorConfiguration="SampleServiceBehavior" in service i.e. < service name="PaymentService.Service1" behaviorConfiguration="SampleServiceBehavior"> has solved problem. Thank u khlr for this answer.

通过在服务中添加behaviorConfiguration =“SampleServiceBehavior”,即 已解决问题。谢谢你khlr这个答案。

#2


0  

As you've configured multiple endpoints I think you'll have to define a <baseAddress>-node.

在配置多个端点时,我认为您必须定义 -node。

Did you already try to get that service working with only one endpoint configured (ideally basicHttpBinding)? This way you can try step by step enhancing your service with other endpoints.

您是否已尝试仅使用一个端点配置该服务(理想情况下为basicHttpBinding)?这样,您可以尝试逐步增强与其他端点的服务。

Another good idea would be to add a svclog into a <system.diagnostics>-node which could provide additional error details. Have a look at this: http://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx

另一个好主意是将svclog添加到 -node中,这可能会提供其他错误详细信息。看看这个:http://msdn.microsoft.com/en-us/library/ms733025(v = vs1010).aspx

Edit

Error was caused by a mistake in the configuration. Solution was putting the behaviorConfiguration-attribute into the right place.

错误是由配置错误引起的。解决方案是将behaviorConfiguration属性放在正确的位置。

#3


0  

After doing this i faced another issue with rest and soap both. It was multiple end point found in service. For solving this name should be added in end point ex < endpoint name="wsSoap" address="soapWs" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="PaymentService.IService1"/>. I added another answer for if user face this kind of issue if their multiple end point successfully worked.

在这样做后,我面临另一个问题,休息和肥皂。这是服务中发现的多个终点。为解决此问题,应在端点ex 中添加此名称。我添加了另一个答案,如果用户遇到这种问题,如果他们的多个终点成功运行。

#1


0  

By adding behaviorConfiguration="SampleServiceBehavior" in service i.e. < service name="PaymentService.Service1" behaviorConfiguration="SampleServiceBehavior"> has solved problem. Thank u khlr for this answer.

通过在服务中添加behaviorConfiguration =“SampleServiceBehavior”,即 已解决问题。谢谢你khlr这个答案。

#2


0  

As you've configured multiple endpoints I think you'll have to define a <baseAddress>-node.

在配置多个端点时,我认为您必须定义 -node。

Did you already try to get that service working with only one endpoint configured (ideally basicHttpBinding)? This way you can try step by step enhancing your service with other endpoints.

您是否已尝试仅使用一个端点配置该服务(理想情况下为basicHttpBinding)?这样,您可以尝试逐步增强与其他端点的服务。

Another good idea would be to add a svclog into a <system.diagnostics>-node which could provide additional error details. Have a look at this: http://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx

另一个好主意是将svclog添加到 -node中,这可能会提供其他错误详细信息。看看这个:http://msdn.microsoft.com/en-us/library/ms733025(v = vs1010).aspx

Edit

Error was caused by a mistake in the configuration. Solution was putting the behaviorConfiguration-attribute into the right place.

错误是由配置错误引起的。解决方案是将behaviorConfiguration属性放在正确的位置。

#3


0  

After doing this i faced another issue with rest and soap both. It was multiple end point found in service. For solving this name should be added in end point ex < endpoint name="wsSoap" address="soapWs" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="PaymentService.IService1"/>. I added another answer for if user face this kind of issue if their multiple end point successfully worked.

在这样做后,我面临另一个问题,休息和肥皂。这是服务中发现的多个终点。为解决此问题,应在端点ex 中添加此名称。我添加了另一个答案,如果用户遇到这种问题,如果他们的多个终点成功运行。