Travist6983 Posted March 21, 2014 Share Posted March 21, 2014 I will warn you that i have never used PHP to call a web service but have spent the last 2 days googling with trial and error and think that i have come to a point where i have no idea what to do as nothing is working. Here is my PHP code... <?php $soapclient = new SoapClient('Link-To-EndPoint'); $params = array('Username' => 'Username', 'Password' => 'Password', 'clientRequestId' => 1, 'projectNumber' => 64111, 'requestDateTime' => '2014-03-16T11:05:24.572Z', 'itemNumber' => 'F00573019120B', 'projectNumber' => 64111 ); $response = $soapclient->GetItemDetailInfo($params); echo '<pre>'; var_dump($response); echo '</pre>'; ?> And here is the request, probably worth noting that this gives the full response and works when i use SOAP UI to make the request. <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <env:Header> <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <UsernameToken> <Username>Username</Username> <Password>Password</Password> </UsernameToken> </Security> </env:Header> <env:Body> <getItemDetailInfoRequest> <requestHeader> <clientRequestId>1</clientRequestId> <projectNumber>64111</projectNumber> <requestDateTime>2014-03-20T14:05:24.572Z</requestDateTime> </requestHeader> <getItemDetailInfoList> <itemDetailSearchCriteria> <itemNumber>F00573019120B</itemNumber> <projectNumber>64111</projectNumber> </itemDetailSearchCriteria> </getItemDetailInfoList> </getItemDetailInfoRequest> </env:Body> </env:Envelope> When i load the page i get a blank screen nothing comes out from $response, I have no idea if i am close to making this work or if i am super far off with this. Using the above code i am able to make a public weather SOAP Web Service work which makes me think i am close. Any help would be appreciated! Link to comment https://forums.phpfreaks.com/topic/287153-using-php-to-call-soap-web-service/ Share on other sites More sharing options...
jairathnem Posted March 21, 2014 Share Posted March 21, 2014 I am completely new to SOAP calls in php. But I did give it a try based on help from google. <?php $client = new SoapClient("http://www.webservicex.net/globalweather.asmx?WSDL",array('proxy_host' => "myproxy", 'proxy_port' => 8080)); $params = array("CountryName" => "united states"); $response = $client->__soapCall("GetCitiesByCountry",array($params)); var_dump($response); ?> and it did generate the needed output. although when I changed $response = $client->__soapCall("GetCitiesByCountry",array($params)); to $response = $client->GetCitiesByCountry(array($params)); It didnt work, and threw and error.This might help. (proxy setting not necessary). Link to comment https://forums.phpfreaks.com/topic/287153-using-php-to-call-soap-web-service/#findComment-1473466 Share on other sites More sharing options...
Travist6983 Posted March 21, 2014 Author Share Posted March 21, 2014 Thanks for the reply yeah i have a working weather one as well that is where my starting code came from <?php $soapclient = new SoapClient('http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL'); $params = array('ZIP' => '48067'); $response = $soapclient->GetCityForecastByZIP($params); echo '<pre>'; var_dump($response); echo '</pre>'; ?> I think there were some issues in my array as well so i have now updated to be this. <?php // Create the client object $soapclient = new SoapClient('Link-To-WSDL-End-Point'); $Header = array( 'UsernameToken' => array( 'Username' => 'Username', 'Password' => 'Password' ) ); $Body = array( 'getItemDetailInfoRequest' => array( 'requestHeader' => array( 'clientRequestId' => 1, 'projectNumber' => 64111, 'requestDateTime' => '2014-03-20T14:05:24.572Z' ), 'getItemDetailInfoList' => array( 'itemDetailSearchCriteria' => array( 'itemNumber' => 'F00573019120B', 'projectNumber' => 64111 ) ) ) ); $response = $client->__soapCall("UsernameToken",array($Header), "getItemDetailInfoRequest",array($Body)); // $response = $soapclient->UsernameToken($Header)->getItemDetailInfoRequest($Body); echo '<pre>'; var_dump($response); echo '</pre>'; ?> Link to comment https://forums.phpfreaks.com/topic/287153-using-php-to-call-soap-web-service/#findComment-1473473 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.