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 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿