1

我们有两个相同 WCF 服务的实例,一个在 Visual Studio 2010 (IIS Express) 中运行,另一个在 IIS Server 7 中运行。我们使用 PHP5 本机 SOAP 调用来访问该服务。

在访问 Visual Studio 实例时,它运行良好,没有任何问题。但是当尝试访问 IIS 7 实例时,我们得到Uncaught SoapFault exception如下信息:

PHP Fatal error:  SOAP-ERROR: Parsing Schema: can't import schema from 'http://example.com/WCFService/Service.svc?xsd=xsd0' in C:\\xampp\\htdocs\\synergy_client\\test.php on line 2
PHP Fatal error:  Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema from 'http://example.com/WCFService/Service.svc?xsd=xsd0' in C:\\xampp\\htdocs\\synergy_client\\test.php:2\nStack trace:\n#0 C:\\xampp\\htdocs\\synergy_client\\test.php(2): SoapClient->SoapClient('[http://]example.com...')\n#1 {main}\n  thrown in C:\\xampp\\htdocs\\synergy_client\\test.php on line 2

用于访问该服务的 PHP 代码是:

<?php
$client = new SoapClient("[http://]example.com/WCFService/Service.svc?wsdl");
$result2 = $client->LoginAdmin(array('username' => "username",'password' => "password"));

IIS 7 实例的 web.conf 是:

    <?xml version="1.0"?>
   <configuration>
    <system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
    <assemblies>
        <add assembly=...../>
      </assemblies>
    </compilation>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

Visual Studio 实例的 web.conf(按预期运行):

    <?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

由于我们是 .Net 新手,因此我们需要您的帮助来解决问题。

附加信息:localhost 被 example.com [http://] 替换为 http://,因为我无法放置链接。

编辑: 这是直接在浏览器中访问 wsdl 时生成的脚本。

<wsdl:definitions name="Service" targetNamespace="http://tempuri.org/">
<wsdl:types><xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://localhost/WCFService/Service.svc?xsd=xsd0" namespace="http://tempuri.org/"/>
<xsd:import schemaLocation="http://localhost/WCFService/Service.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
<xsd:import schemaLocation="http://localhost/WCFService/Service.svc?xsd=xsd2" namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
</xsd:schema></wsdl:types><wsdl:message name="IService_LoginAdmin_InputMessage"><wsdl:part name="parameters" element="tns:LoginAdmin"/>
</wsdl:message>
.......
4

2 回答 2

0

得到解决方案!谢谢 Luuk 的及时回复和时间来建议解决方案,正如它所说

`can't import schema from http://example.com/WCFService/Service.svc?xsd=xsd0'

我试图通过浏览器访问架构链接并得到 404 错误。然后谷歌搜索并找到以下解决方案。

Allow access for IIS_IUSERS to the folder 'C:/Windows/Temp'

希望这个答案对某人有所帮助。

于 2013-02-15T10:16:49.203 回答
0

更改架构位置,因为 phpclient 可能不在托管 wcf 服务的同一台服务器上运行。您可以在 serviceMetadata 中更改它:

<serviceMetadata httpGetEnabled="true" httpGetUrl="http://example.com/WCFService/Service.svc"  />

资料来源: 如何更改 WCf 服务的 wsdl 文件中的默认模式位置?

于 2013-02-12T13:51:07.853 回答