Question
· 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-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,

Discussion (12)0
Log in or sign up to continue

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);

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 ?

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 ?

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)

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>

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>