Unable to access WCF in IIS from PHP SOAP

We have two instances of the same WCF service, one of which works in Visual Studio 2010 (IIS Express), and the other on the IIS 7 server. We use our own PHP5 SOAP calls to access the Service.

When accessing an instance of Visual Studio, it works without problems. But when we try to access the IIS 7 instance, we get 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\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 code used to access the service:

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

web.conf instance of IIS 7:

  <?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 instance of Visual Studio (which works 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 problem.

Additional information: localhost is replaced by example.com [http: //] for http: //, since I can’t post links.

Edit: This is a script generated wsdl access directly in the 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> ....... 
+1
source share
2 answers

Got a solution! Thank you Luuk for your prompt reply and time to propose solutions, as was said

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

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

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

Hope this answer helps someone.

0
source

Modify the schema because phpclient probably does not work on the same server as the wcf service. You can change it in serviceMetadata:

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

Source: How to change the default schema in the WCs service wsdl file?

0
source

Source: https://habr.com/ru/post/1314831/


All Articles