RNK
RNK

Reputation: 5792

SOAP Fault: fault code: VersionMismatch, fault string: Wrong Version

Our requirement is to send request through SOAP1.2. I am using below code in PHP.

$basic_auth = base64_encode(USERNAME.':'.PASSWORD);
$opts = array(
    'http'=>array(
            'header' => "Authorization: Basic $basic_auth
                         x-ibm-client-id: $client_id
                         x-ibm-client-secret: $client_secret"
        )
    );
$context = stream_context_create($opts);
$soap_client = new SoapClient(WSDL, array("trace"=>1,
                                              "local_cert"=>"/var/www/cert.pem",
                                              "passphrase"=>"xxxxx",
                                              "soap_version"=>SOAP_1_2,
                                              "exeptions"=>true,
                                              "stream_context"=>$context,
                                              "location"=>LOCATION
                                              ));
try{
    $params = array(
        'getBalance' => array(
            'version' => 1,
            'partnerCode'=>PARTNER_CODE
        ));
    $post_response = $soap_client->__soapCall('getBalance', $params);
    return $post_response;
}
catch(SoapFault $fault){
    highlight_string($soap_client->__getLastRequestHeaders());
    highlight_string($soap_client->__getLastRequest());
    die("SOAP Fault: fault code: {$fault->faultcode}, fault string: {$fault->faultstring}");
}

Error I am getting is below:

SOAP Fault: fault code: VersionMismatch, fault string: Wrong Version

How can I check it weather request is actually using SOAP12?

Upvotes: 1

Views: 7018

Answers (1)

Kris Peeling
Kris Peeling

Reputation: 1025

You can check if your SOAP request is using the correct version by inspecting the request XML. After your request, examine the the XML:

var_dump($soap_client->__getLastRequest());

Note the namespaces used in the envelope declaration.

SOAP 1.2: http://www.w3.org/2003/05/soap-envelope

SOAP 1.1 http://schemas.xmlsoap.org/soap/envelope/

Upvotes: 2

Related Questions