1

I'm trying to use a Web Service using PHP and SOAP. The Web Service is built in .NET and hosted on an ASP server. I'm using the following code to interact with the API but I keep getting an error with parsing WSDL. The PHP UNIX server has an SSL certificate, the web service host also has an SSL certificate and I'm using https to initiate the transaction.

This particular API call requests a string for a membership number:

$wsdl='https://domain.com/ws.asmx?wsdl';

$client=new SOAPClient($wsdl, array('exceptions'=>0));

$result=$client->IsMemberCurrent('123456789');

Error:

Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'domain/ws.asmx?wsdl' : Start tag expected, '<' not found in index.php on line 4

I can see the WSDL contents but the error message I'm getting via PHP suggests it either can't see or can't process the WSDL file?

SOAP 1.2 service description:POST /SubscriberAPI.asmx HTTP/1.1
Host: subdomain.domain.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <IsMemberCurrent xmlns="http://www.domain.com/">
      <MembershipNo>string</MembershipNo>
    </IsMemberCurrent>
  </soap12:Body>
</soap12:Envelope>

1 Answer 1

0

It seems that you cannot access the WSDL file. So you need to diagnose the issue.

Try

echo htmlentities(file_get_contents($wsdl));

It will give you better insight as to what PHP gets as a response.

Once you have got the SoapClient working your next line of code will not work as expected.

You need wrap your parameter in an associative array otherwise the web service will not recognize it.

Also the response returned by the .NET web service will be a IsMemberCurrentResponse object, which contains a IsMemberCurrentResult, so you need to replace your last line with the following.

$params = array('MembershipNo'=>'1234567890');
$response = $client->IsMemberCurrent($params);
$result = $response->IsMemberCurrentResult;
Sign up to request clarification or add additional context in comments.

18 Comments

Thanks for the tip. I've done as suggested, but the return I get is the same - couldn't load error. Could this mean a Firewall issue since I am able to see the WSDL file when I try to access it directly from the web browser?
If it errors on file_get_contents then it is an issue connecting to the IIS box and not an issue with IIS or ASP.NET. It could be a firewall issue - but need some more information. Do you get any more information other than couldn't load? Is the web browser you are using located on the UNIX server? Can you try over http rather than https?
My web server uses PHP/UNIX and I've tried both HTTP and HTTPS but the error I get is that it can't parse the WSDL file. The error message you see in my original post is all of the information that PHP is showing unless there's any debug methods that can be used to extract more info?
The line of code I asked you to try shouldn't have given you a "can't parse the WSDL file" error as it wouldn't have attempted to parse anything. You'd need to execute that line in a new PHP document or comment out the SoapClient lines. If that's what you did then I'd recommend using a browser on the UNIX server to see what is returned, if you get an error you can go from there, otherwise if all is okay then it will be PHP specific.
I'm not sure what you mean by parameter? Could you clarify this. WSDL has the following defined: <wsdl:message name="IsMemberCurrentSoapIn"> <wsdl:part name="parameters" element="tns:IsMemberCurrent"/> </wsdl:message> <wsdl:message name="IsMemberCurrentSoapOut"> <wsdl:part name="parameters" element="tns:IsMemberCurrentResponse"/>
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.