cancel
Showing results for 
Search instead for 
Did you mean: 

SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL:

Former Member
0 Kudos

I tried to call a ABAP webservice from PHP (/people/anton.wenzelhuemer/blog/2006/03/05/integrating-php-and-abap-using-webservices). I getting the following error,

<i>Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://<servername>:<port>/sap/bc/srt/rfc/sap/zkb_test_rfc?sap-client=100&wsdl=1.1' in C:\php-5\webapps\webservices\CallSAP.php:15 Stack trace: #0 C:\php-5\webapps\webservices\CallSAP.php(15): SoapClient->__construct('http://<servername>...', Array) #1 thrown in C:\php-5\webapps\webservices\CallSAP.php on line 15</i>

This is my PHP code,

[code]

<?php

$wsdlurl ="http://<servername>:<port>/sap/bc/srt/rfc/sap/ZKB_TEST_RFC?sap-client=100&wsdl=1.1";

$login = "<UserName>";

$password = "<Password>";

$name = "Kathirvel";

?>

<HTML><HEAD><TITLE>Call SAP WebService</TITLE></HEAD>

<BODY>

<?php

$client = new SoapClient($wsdlurl,

array('login' => $login,

'password' => $password,

'trace' => true,

'exceptions' => true));

try {

echo $client->ZKB_TEST_RFC(array('INPUT_TEXT' => $name))->OUTPUT_TEXT;

}

catch (SoapFault $e) {

echo 'Caught an Error: [' . $e->faultcode . '] - ' . $e->faultstring;

}

echo "<hr><pre>\n";

echo "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n";

echo "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";

echo "</pre>";

?>

</BODY></HTML>

[/code]

The ABAP code is a simple one, a RFC enabled FM that was converted into webservice,

[code]

*"----


""Local Interface:

*" IMPORTING

*" VALUE(INPUT_TEXT) TYPE STRING OPTIONAL

*" EXPORTING

*" VALUE(OUTPUT_TEXT) TYPE STRING

*"----


CONCATENATE 'Welcome' input_text INTO output_text SEPARATED BY space.

[/code]

Any help would be appreciated.

Regards

Kathirvel

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi kathirvel,

I suppose you're behind a proxy.

add this to the constructor:

      
      'proxy_host'     => "proxyhost",
      'proxy_port'     => proxyport,    // enter a integer not a string!!!
      'proxy_login'    => "proxy_login",
      'proxy_password' => "proxy_password",

hope it helps and have fun with my tutorial,

anton

Former Member
0 Kudos

Thanks Anton,

You are correct, I am behind a proxy.

I will update my code and give a try. I will get back to you with the results.

Thanks

Kathirvel

Former Member
0 Kudos

yw.

btw, if you don't need to authenticate at your proxy, just omit proxyuser and proxypassword.

Former Member
0 Kudos

Hi Anton

I changed the constructor as

[code]

$client = new SoapClient($wsdlurl,

array('login' => $login,

'password' => $password,

'trace' => true,

'exceptions' => true,

'proxy_host' => $proxy_host,

'proxy_port' => $proxy_port,

'proxy_login' => $proxy_login,

'proxy_password' => $proxy_password ));

[/code]

Still I get the same error. And so is this one too,

[code]

$client = new SoapClient($wsdlurl,

array('login' => $login,

'password' => $password,

'trace' => true,

'exceptions' => true));

[/code]

Any help

Regards

Kathirvel

Former Member
0 Kudos

hi,

did you ensure that your proxy_port is type integer?

$proxy port = 8080; // <- correct

$proxy_port = '8080'; // <- wrong

Former Member
0 Kudos

Yes anton,

I gave the value as integer i.e. $proxy_port = 3128;

But still I get the same error.

Regards

Kathirvel

Former Member
0 Kudos

hmmm.

notice that (SAP) username & password are to be entered in correct case.

try to modify the WSDL URL to include sap-user and sap-password

...&sap-user=XXXYYz&sap-password=12345A1b

next thing I'd try is to download (view the wsdl in a browser, right click, show source, save as...)the wsdl and save it to the same directory as your script, then modify the constructor to access that file...

$wsdlfile = "myfile.wsdl";

$client = new SoapClient($wsdlurl, array($wdslfile, ...)

this should give you a hint if there's an error with your wsdl or only accessing the WSDL

Another possible error might arise from a non-resolvable service endpoint (i.e. the actual address being called when you invoke a service operation). If this has no fully qualified domain name or if that servername is not resolvable from the network segment where your php script is being executed then no route to the service can befound.

we'll get that going, don't worry

anton

Former Member
0 Kudos

oops, the constructor given is wrong.

it has to be

$client = new SoapClient($wsdlfile, array(...

Message was edited by:

Anton Wenzelhuemer

Former Member
0 Kudos

Hi Anton,

I tried your second suggestions & it was fruitful. It gave me the clue to the problem,

<i>$wsdlfile = "myfile.wsdl";

$client = new SoapClient($wsdlurl, array($wdslfile, ...)</i>


Request :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:sap-com:document:sap:rfc:functions">
<SOAP-ENV:Body>
<ns1:ZKB_TEST_RFC><ns1:INPUT_TEXT>Kathirvel</ns1:INPUT_TEXT></ns1:ZKB_TEST_RFC>
</SOAP-ENV:Body></SOAP-ENV:Envelope>

Response:
<HTML><HEAD>
<TITLE>Network Error</TITLE>
</HEAD>
<BODY>
<FONT face="Helvetica">
<big><strong></strong></big><BR>
</FONT>
<blockquote>
<TABLE border=0 cellPadding=1 width="80%">
<TR><TD>
<FONT face="Helvetica">
<big>Network Error (dns_unresolved_hostname)</big>
<BR>
<BR>
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica">
Your requested host "<host name>" could not be resolved by DNS.
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica">

</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica" SIZE=2>
<BR>
For assistance, contact your network support team.
</FONT>
</TD></TR>
</TABLE>
</blockquote>
</FONT>
</BODY></HTML>

<b>I am able to ping <host name>, also connect to that address using my browser. But the soap call alone is failing.</b>

Regards

Kathirvel

Message was edited by:

Kathirvel Balakrishnan

Former Member
0 Kudos

good. i mean, bad. this happens often.

two workarounds to that:

1) static: correct the endpoint URL in the downloaded WSDL (next to the end of the file) manually and use this WSDL

2)dynamic: enable the curl library in PHP (it allows you to fetch arbitrary webpages, including WSDLs)

[code]

...

$url = "http://the_wsdl_url"

$ch = curl_init();

curl_setopt($ch, CURLOPT_POST, 0);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt($ch, CURLOPT_HEADER, 1);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

curl_setopt($ch, CURLOPT_PROXY, "http://proxy_server:proxyport");

curl_setopt($ch, CURLOPT_PROXYPORT, 3128);

curl_setopt($ch, CURLOPT_URL, $url);

$page = curl_exec($ch);

...

[/code]

parse the resulting WSDL, find the service endpoint URL and replace it using regex-functions like preg_replace, save to a temporary file and feed this file to the constructor of the SOAP client object.

easier for you:

3) let the network buddies suggest and implement a solution to correctly route your request.

anton

Former Member
0 Kudos

well,

the rponse you supplied (HTML page) is not generated by PHP but it comes from the proxy you configured.

If you can ping the service endpoint server and load the server's homepage into the browser, then windows is using another proxy then the one you configured.

try another proxy.

Former Member
0 Kudos

Hi Anton,

I am working on 1 & 3 options. But meanwhile I do not have much idea with the steps in option 2. Could you please explain in details?

Thanks

Kathirvel

Former Member
0 Kudos

Kathirvel,

I'd forget option 2) at the moment. It is useful only when

- you can access the WSDL from your script

- and you can't access the endpoint

I'd really try to find a working proxy.

anton

Former Member
0 Kudos

I think you are absolutely right Anton. Only the right proxy will do the trick. Hope this solve the proble. I am closing the thread. Thanks a lot for the help.

Regards

Kathirvel

Answers (0)