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 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据