本文介绍了托管在 Windows 服务中的 WCF 服务 (basicHttpBinding) 的 WSDL URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我们的一台服务器上的 Windows 服务中托管 WCF 服务.在 basicHttpBinding 中使其工作并在 .NET 中构建测试客户端(最终工作)后,我继续尝试使用 SoapClient 类从 PHP 访问它.最终消费者将是一个 PHP 站点,因此我需要使其在 PHP 中可以使用.

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.

当我不得不在 PHP 代码的 SoapClient 类的构造函数中输入 WSDL url 时,我被难住了.WSDL 在哪里?我只有:

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/WordServicehttp://172.27.7.123:8000/WordService/mex

这些都不会公开 WSDL.

None of these do not expose WSDL.

作为 WCF 的新手,我可能会问一些愚蠢的问题(或者我可能在某处有错误的假设).请温柔:D

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

不,http://172.27.7.123:8000/WordService?wsdl 没有显示任何不同于 http://172.27.7.123:8000/WordService :(

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

我是否被迫在 IIS 中托管它?我是否被迫使用常规 WebService?

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

推荐答案

这可能会有所帮助:

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>

不要忘记删除 XML 注释,因为它们在原处无效.

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

这篇关于托管在 Windows 服务中的 WCF 服务 (basicHttpBinding) 的 WSDL URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 15:19