Skip to content

Instantly share code, notes, and snippets.

@marifrahman
Created March 24, 2012 13:44
Show Gist options
  • Save marifrahman/2183008 to your computer and use it in GitHub Desktop.
Save marifrahman/2183008 to your computer and use it in GitHub Desktop.
PHP SOAP Client to consume JAX-WS with Basic Http Authentication
<?php
class JaxWsSoapClient extends SoapClient
{
public function __call($method, $arguments){
$response = parent::__call($method, $arguments);
return $response->return;
}
}
ini_set('soap.wsdl_cache_enabled',0);
ini_set('soap.wsdl_cache_ttl',0);
try {
$client = new JaxWsSoapClient("http://192.168.124.11:8080/url_to_wsdl?wsdl",
array("trace" => 1,
"location" =>"http://192.168.124.11:8080/service_end_point",
"uri" =>"http://name_space/",
"login" => "my_user_name",
"password" => "my_password"
));
$result = $client->getDataWS(array(
"crmSearchInfo" => array(
"additionalInformations" => NULL,
"useDateFilter" => NULL,
"searchKeyValue" => "value_to_search"
) ));
//echo"<br/>Dumping request headers:<br/>".$client->__getLastRequestHeaders();
echo("<br/>Dumping request:<br/>".$client->__getLastRequest());
//echo("<br/>Dumping response headers:<br/>".$client->__getLastResponseHeaders());
//echo("<br/>Dumping response:<br/>".$client->__getLastResponse());
echo("<br/>Returning value of __soapCall() call: ");
var_dump($result->resultDataMap);
}catch(SoapFault $exception)
{
print_r("Got issue:<br/>") ;
print_r($exception->getMessage());
}
?>
@josimarjimenez
Copy link

hi, can you help me, how can I obtain the login and password in java. Thanks....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment