Errror SOAPACTION value when I call a webservice
Hello all,
When I call a WSDL in php, look this code :
// Standard SOAP header for username/password
// From http://stackoverflow.com/questions/13465168/php-namespaces-in-soapheader-child-nodes
class WSSESecurityHeader extends SoapHeader {
public function __construct($username, $password)
{
$wsseNamespace = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secex...';
$security = new SoapVar(
array(new SoapVar(
array(
new SoapVar($username, XSD_STRING, null, null, 'Username', $wsseNamespace),
new SoapVar($password, XSD_STRING, null, null, 'Password', $wsseNamespace)
),
SOAP_ENC_OBJECT,
null,
null,
'UsernameToken',
$wsseNamespace
)),
SOAP_ENC_OBJECT
);
parent::SoapHeader($wsseNamespace, 'Security', $security, false);
}
}
// Key parameters for connecting to the web service:
$location = "http://IP:PORT/csp/dsa-cla-prd/com.siemens.med.hs.Country.WebServices.pats.ClassPatientServices.cls";
$uri = "http://intersystems.fr";
$username = "USER";
$password = "PASS";
// If the soap client is to be constructed from the WSDL, or if the WSDL is to be used to generate
// PHP classes (using various tools that exist for that purpose), ?WSDL=1 and the username/password
// need to be tacked on to the end of the URL:
$wsdl = $location . "?WSDL=1&CacheUserName=" . $username . "&CachePassword=" . $password;
echo $wsdl.str_repeat('<br />', 4);
// Create SoapClient Object
$client = new SoapClient(null, array(
"trace" => 1,
"location" => $location,
"uri" => $uri,
"style" => SOAP_DOCUMENT,
"use" => SOAP_LITERAL));
// Add security header.
$client->__setSoapHeaders(new WSSESecurityHeader($username, $password));
//echo '<xmp>';
//print_r($client);
//echo '</xmp>';
// Object with parameter names and values for the SOAP call
try {
$clsINOUTContext = new stdClass();
$clsINOUTContext->AccessCode = 'ACC';
$ClsOUTInfosPatient = new stdClass();
$params = array(
'clsINOUTContext' => $clsINOUTContext,
'strINPatientIPP' => "11111111",
'ClsOUTInfosPatient' => $ClsOUTInfosPatient
);
echo '<xmp>';
print_r($params);
echo '</xmp>';
$return = $client->GetPatientInfo($params);
var_dump($return);
} catch (Exception $e) {
echo "Exception occured: " . $e;
}
I have this error :
Exception occured: SoapFault exception: [SOAP-ENV:Client] Erreur dans le WebService: Erreur interne détectée. ERROR #6207: Unexpected SOAPACTION value: http://intersystems.fr#GetPatientInfo in C:\wamp\www\clinicom_webservice\index.php:81 Stack trace: #0 C:\wamp\www\clinicom_webservice\index.php(81): SoapClient->__call('GetPatientInfo', Array) #1 C:\wamp\www\clinicom_webservice\index.php(81): SoapClient->GetPatientInfo(Array) #2 {main}
Can you help me ?
Thanks a lot for explains,
It looks like some of this may have come from https://community.intersystems.com/post/example-connecting-cach%C3%A9-web-service-php
The remainder of that example may also be useful, for demonstrating how to use the correct SOAPACTION (which the error message you have refers to). This entails using __soapCall with an array of options including the expected SOAPACTION value.
Thanks for your help it's run better,
but now I have this error :
Exception occured: SoapFault exception: [SOAP-ENV:Client] Erreur dans le WebService: Erreur interne détectée. ERROR #6237: Unexpected tag in XML input: AccessCode (ending at line 2 character 379). in C:\wamp\www\clinicom_webservice\index.php:93 Stack trace: #0 C:\wamp\www\clinicom_webservice\index.php(93): SoapClient->__soapCall('GetPatientInfo', Array, Array) #1 {main}
My code :
//
$IPP = '111111113';
//
$clsINOUTContext = new stdClass();
$clsINOUTContext->AccessCode = 'CWP';
//
$ClsOUTInfosPatient = new stdClass();
$params = array(
'clsINOUTContext' => $clsINOUTContext,
'strINPatientIPP' => $IPP,
'ClsOUTInfosPatient' => $ClsOUTInfosPatient
);
$options = array('soapaction'=>$uri.'/[Country].WebServices.pats.ClassPatientServices.GetPatientInfo');
//Call WS
$result = $client->__soapCall("GetPatientInfo",$params,$options);
var_dump($result);
Can you help me ?
Perhaps consider using SOAP logging (see documentation) to compare a valid request from a web client that works (using a Caché-based client or a third-party tool like SoapUI) to what your PHP client is sending - that might make it more obvious how the correct XML differs from what PHP is sending.
hello all !
I progress it's a good news ;-), so now I have this code :
try {
//
$clsINOUTContext = new StdClass();
$clsINOUTContext->ClsINOUTContext = new StdClass();
$clsINOUTContext->ClsINOUTContext->AccessCode = 'AAA';
//
$params = array(
'ClsINOUTContext' => $clsINOUTContext,
'strINPatientIPP' => "11111111"
);
echo '<xmp>';
print_r($params);
echo '</xmp>';
$options = array('soapaction'=>$uri.'/[URL].ClassPatientServices.GetPatientInfo');
//Call WS
$result = $client->__soapCall("GetPatientInfo",$params,$options);
var_dump($result);
} catch (Exception $e) {
echo "Exception occured: " . $e;
The result is this :
You know the problem because i send the IPP in string ?
Hello
No ideas about my last problem ?
Thanks
Hello,
I'm not very far from the result, what's missing ? Help me please
Thanks a lot
Is the GetPatientInfo method of your com.siemens.med.hs.Country.WebServices.pats.ClassPatientServices class responding with that message?
Yes, this is the reply:
Can you read the Caché ObjectScript code that implements the GetPatientInfo method in the com.siemens.med.hs.Country.WebServices.pats.ClassPatientServices class, and work out why it returns ErrDesc="Erreur: IPP manquant." ?
Yes this is my SOAP request:
<SOAP-ENV:Envelope xmlns:ns1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secex..." xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<ns1:Security>
<ns1:UsernameToken>
<ns1:Username>USERNAME</ns1:Username> <ns1:Password>USERPASS</ns1:Password> </ns1:UsernameToken> </ns1:Security> </SOAP-ENV:Header>
<SOAP-ENV:Body>
<param0>
<ClsINOUTContext>
<AccessCode>CCP</AccessCode> </ClsINOUTContext>
</param0>
<param1>
<strINPatientIPP>11111111</strINPatientIPP> </param1>
</SOAP-ENV:Body> </SOAP-ENV:Envelope>
Hello,
You can't help me more ?
Please
Yes this is my SOAP request:
<SOAP-ENV:Envelope xmlns:ns1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secex..." xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<ns1:Security>
<ns1:UsernameToken>
<ns1:Username>USERNAME</ns1:Username> <ns1:Password>USERPASS</ns1:Password> </ns1:UsernameToken> </ns1:Security> </SOAP-ENV:Header>
<SOAP-ENV:Body>
<param0>
<ClsINOUTContext>
<AccessCode>CCP</AccessCode> </ClsINOUTContext>
</param0>
<param1>
<strINPatientIPP>11111111</strINPatientIPP> </param1>
</SOAP-ENV:Body> </SOAP-ENV:Envelope>