NuSoap - How to use a local, existing WSDL file in nusoap_client PHP

I am new to nusoap and web services in general.

The wsdl file comes from the client. I have a basic web service working with a default url that supplies wsdl via the web address: http://hiddenurl.com/ws/schema/Terminal.wsdl

But the client documentation says: "Please download the WSDL files and XML schemas locally to use your code. Do not use these files every time from our server."

So, I'm trying to host a wsdl file locally or through my own web server, but none of them worked.

I tried:

 $wsdlUrl = 'http://supplied-url.com/schema/Terminal.wsdl' // working but discouraged $wsdlUrl = 'http://my-own-IIS-based-url/schema/Terminal.wsdl' // url loads and I can // view wsdl file, but when I load run webservice is returns blank / nothing $wsdlUrl = 'path/to/local/Terminal.wsdl' // returns blank or 'boolean'false' $tempUrl = realpath('path/to/local/Terminal.wsdl') // get absolute url wsdlUrl = tempUrl; // returns blank screen or 'boolean'false' 

Is there a way that the web service can use the wsdl file from a different place than what was originally provided by the client? I saw some links to web servers returning wsdl from some kind of http: //getfile.php? File.wsdl , but I don't understand what it would be in 'getfile.php' to deliver wsdl via the query string.

Here is my PHP code for calling a web service. Again, it works with the client URL for the wsdl file, but not when I try to access the wsdl file in any other way.

 <?php require_once('nusoap.php'); $URI = 'http://api.hiddenurl.com/ws/schema'; $env = 'api'; $wsdlUrl = 'http://'.$env.'.hiddenurl.com/schema/Terminal.wsdl'; $licenseKey = 'xxxx-xxxx-xxxx-xxxx-xxxx'; $userName = 'user'; $password = 'password'; $service = new nusoap_client($wsdlUrl, true); // login credentials $service->setHeaders( '<wsse:Security xmlns:wsse="http://hiddenurl.xsd">'. '<wsse:UsernameToken>'. '<wsse:Username>'.$userName.'</wsse:Username>'. '<wsse:Password Type="http://hiddenurl#PasswordText">'.$password.'</wsse:Password>'. '</wsse:UsernameToken>'. '</wsse:Security>' ); $msg = '<GetDetailsRequest xmlns="'.$URI .'">'. '<messageId></messageId>'. '<version></version>'. '<licenseKey>'.$licenseKey.'</licenseKey>'. '<iccids>'. '<iccid>'.'xxxxxxxxxxxxxxx'.'</iccid>'. '</iccids>'. '</GetDetailsRequest>'; $result = $service->call('GetlDetails', $msg); if ($service->fault) { echo 'faultcode: ' . $service->faultcode . "\n"; echo 'faultstring: ' . $service->faultstring . "\n"; echo 'faultDetail: ' . $service->faultdetail . "\n"; echo 'response: ' . $service->response; exit(0); } echo "<pre>"; var_dump($result); echo "</pre>"; ?> 

Many thanks.

+6
source share
2 answers

try it

 $wsdl_location= realpath('path/to/local/Terminal.wsdl'); $wsdl_cache = new nusoap_wsdlcache("/tmp"); // for caching purposes $wsdl_obj = $wsdl_cache->get($wsdl_location); if (empty($wsdl_obj)) { $wsdl_obj=new wsdl($wsdl_location); $wsdl_cache->put($wsdl_obj); } $service = new nusoap_client($wsdl_obj,true); 
+5
source

Try using the localhost path:

$ wsdlUrl = ' http: //localhost/schema/Terminal.wsdl ';

ps This URL will not work in the browser, but can be executed via php script on the server.

0
source

All Articles