on 12-20-2006 3:19 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
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
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.