Question Emilien Miossec · Apr 12, 2017

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-sece…';
        $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,

Comments

Timothy Leavitt · Apr 12, 2017

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.

// Object with parameter names and values for the SOAP call
$request = new stdClass();
$request->id = $id;

// This goes in an associative array with key FindPersonSoapIn (see WSDL)
$params = array();
$params['FindPersonSoapIn']=$request;

// In the array of options for the soap call, soapaction must be specified since there's no WSDL to refer to.
// PHP provides a default value of <uri>#<method>, but that's incorrect.
$options = array('soapaction'=>$uri.'/SOAP.Demo.FindPerson');

// Actually call the web service
$result = $client->__soapCall("FindPerson",$params,$options);
0
Emilien Miossec · Apr 14, 2017

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 ?

0
Timothy Leavitt  Apr 14, 2017 to Emilien Miossec

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.

0
Emilien Miossec · Apr 18, 2017

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 :

array(size=2)
  'GetPatientInfoResult' =>string'false'(length=5)
  'ClsINOUTContext' =>object(stdClass)[9]
	[...]
      public 'ErrDesc' =>string'Erreur: IPP manquant.'(length=21)public 'ErrorExists' =>string'true'(length=4)public 'ErrCount' =>string'1'(length=1)
    	[...]

You know the problem because i send the IPP in string ?

0
Emilien Miossec · Apr 24, 2017

Hello,

I'm not very far from the result, what's missing ? Help me please

Thanks a lot

0
John Murray  Apr 24, 2017 to Emilien Miossec

Is the GetPatientInfo method of your com.siemens.med.hs.Country.WebServices.pats.ClassPatientServices class responding with that message?

0
Emilien Miossec  Apr 24, 2017 to John Murray

Yes, this is the reply:

array(size=2)
  'GetPatientInfoResult' =>string'false'(length=5)
  'ClsINOUTContext' =>object(stdClass)[10]
      public 'AccessCode' =>string'[ACCCODE]'(length=3)public 'UserName' =>string'[USERNAME]'(length=6)public 'HospID' =>string'01'(length=2)public 'Group' =>string'[GROUPE]'(length=7)public 'Environment' =>string'PRD'(length=3)public 'Status' =>string'MA=='(length=4)public 'ClassFunction' =>string'com.siemens.med.hs.Country.WebServices.pats.ClassPatientServices'(length=62)public 'CurrentFunction' =>string'GetPatientInfo'(length=14)public 'SHSErrCode' =>string'0'(length=1)public 'ErrDesc' =>string'Erreur: IPP manquant.'(length=21)public 'ErrorExists' =>string'true'(length=4)public 'ErrCount' =>string'1'(length=1)public 'AvertExists' =>string'false'(length=5)public 'AvertCount' =>string'0'(length=1)public 'RunAsWebService' =>string'true'(length=4)public 'TraceWrite' =>string'false'(length=5)public 'TraceLogToFile' =>string'false'(length=5)public 'TraceLogFile' =>string'/sms/logfile.txt'(length=16)public 'NameSpace' =>string'[DD]'(length=11)public 'GUID' =>string'[N°]'(length=36)public 'IsInTestMode' =>string'false'(length=5)
0
John Murray  Apr 24, 2017 to Emilien Miossec

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." ?

0
Emilien Miossec  Apr 24, 2017 to John Murray

Yes this is my SOAP request:


<SOAP-ENV:Envelope xmlns:ns1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-sece…" 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>

0
Emilien Miossec  Apr 26, 2017 to Emilien Miossec

Hello,

You can't help me more ?

Please

0
Emilien Miossec · Apr 24, 2017

Yes this is my SOAP request:


<SOAP-ENV:Envelope xmlns:ns1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-sece…" 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>

0