WSDL URL for a WCF Service (basicHttpBinding) hosted inside a Windows Service

左心房为你撑大大i 提交于 2019-12-20 10:39:13

问题


I am hosting a WCF service in a Windows Service on one of our servers. After making it work in basicHttpBinding and building a test client in .NET (which finally worked) I went along and try to access it from PHP using the SoapClient class. The final consumer will be a PHP site so I need to make it consumable in PHP.

I got stumped when I had to enter the WSDL url in the constructor of the SoapClient class in the PHP code. Where is the WSDL? All I have is :

http://172.27.7.123:8000/WordService and http://172.27.7.123:8000/WordService/mex

None of these do not expose WSDL.

Being a newbie in WCF I might have asked a dumb thing (or I might have a wrong assumption somewhere). Please be gentle :D

And no, http://172.27.7.123:8000/WordService?wsdl does not show anything different than http://172.27.7.123:8000/WordService :(

Am I forced to host it in IIS? Am I forced to use a regular WebService?


回答1:


This might help:

http://msdn.microsoft.com/en-us/library/ms734765.aspx

In a nutshell you need to configure your service endpoints and behaviour. Here is a minimal example:

<system.serviceModel>
  <services>

    <service 
      <!-- Namespace.ServiceClass implementation -->
      name="WcfService1.Service1" 

      <!-- User behaviour defined below -->
      behaviorConfiguration="SimpleServiceBehaviour"> 

      <endpoint 
        address="" 
        binding="basicHttpBinding"
        <!-- Namespace.Interface that defines our service contract -->
        contract="WcfService1.IService1"/>

    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="SimpleServiceBehaviour">

        <serviceMetadata 
          <!-- We allow HTTP GET -->
          httpGetEnabled="true" 

          <!-- Conform to WS-Policy 1.5 when generating metadata -->
          policyVersion="Policy15"/>

      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

Don't forget to remove the XML comments as they're invalid where they are.




回答2:


Please see this link:

Exposing a WCF Service With Multiple Bindings and Endpoints

Unlike previous ASMX services, the WSDL (web service definition language) for WCF 
services is not automatically generated.  The previous image even tells us that 
"Metadata publishing for this service is currently disabled.".  
This is because we haven't configured our service to expose any meta data about it. 
 To expose a WSDL for a service we need to configure our service to provide meta information.  Note:  
The mexHttpBinding is also used to share meta information about a service.  While 
the name isn't very "gump" it stands for Meta Data Exchange.


来源:https://stackoverflow.com/questions/167852/wsdl-url-for-a-wcf-service-basichttpbinding-hosted-inside-a-windows-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!