doufengsui7449 2013-02-12 05:32
浏览 79
已采纳

无法从PHP SOAP访问IIS中的WCF

We have two instance of same WCF service, one running in the Visual Studio 2010 (IIS Express) and another in the IIS Server 7. We are using PHP5 native SOAP calls to access the Service.

While accessing the Visual Studio Instance, it works well without any problem. But when trying to access the IIS 7 instance, we are getting an Uncaught SoapFault exception as follows:

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
Stack trace:
#0 C:\\xampp\\htdocs\\synergy_client\\test.php(2): SoapClient->SoapClient('[http://]example.com...')
#1 {main}
  thrown in C:\\xampp\\htdocs\\synergy_client\\test.php on line 2

The PHP code used to access the service is:

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

web.conf of the IIS 7 Instance is:

    <?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>

web.conf of Visual Studio Instance(which is running as expected):

    <?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>

As we are new to .Net, we need your help to solve the issue.

Additional Info: localhost replaced by example.com [http://] for http://, as I cannot place links.

Edit: This is the script generated whe accessing the wsdl directly in a browser.

<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>
.......
  • 写回答

2条回答 默认 最新

  • douduidui1046 2013-02-15 10:16
    关注

    Got the solution! Thank you Luuk for your prompt response and time to sugget the solutions, as it was saying

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

    I tried to access the schema link through browser and got 404 error. Then Googled for that and found the following solution.

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

    Hope this answer helps someone.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?