4

PHP's Soap client appears to be handling arguments with type s1:char incorrectly when building the request. The Soap API requires either 'Y' or 'N' but in the request XML I get '0'. (Passing Bool true results in '1' but that isn't accepted as API in place of 'Y').

I'm using PHP Version 5.3.8 with the native Soap Client

Here's my PHP

$this->soapClient = new SoapClient( $client->wsdl,
  array(
    'soap_version' => SOAP_1_2,
    'trace' => true
  )
);

$result = $this->soapClient->SomeSoapMethod(array(
  'sSessionKey'        => $sessionKey,
  // other string and int args that work fine here
  'cReturnNonSeats'    => 'Y' // API wants 'Y' or 'N'
));

The relevant XML node in the request XML:

<ns1:cReturnNonSeats>0</ns1:cReturnNonSeats>

And from the WSDL:

    <s:complexType>
      <s:sequence>
        <s:element minOccurs="1" maxOccurs="1" name="cReturnNonSeats" type="s1:char" />
      </s:sequence>
    </s:complexType>

Without getting into building XML manually, is there a way I can have some control over how these arguments are typecast?

hakre
  • 193,403
  • 52
  • 435
  • 836
DavidNorth
  • 450
  • 3
  • 14

1 Answers1

2

This is how I got around it though I'd like to now why SoapClient is converting that string to int.

Instead of 'Y' in my array of parameters, I used:

new SoapVar('Y', XSD_ANYTYPE)
DavidNorth
  • 450
  • 3
  • 14
  • 2
    Although this does produce an XML response with 'Y' for the character, it turns out what the SOAP service actually wants is an int for the ASCII of 'Y' or 'N', so the real solution is: ord('Y') – DavidNorth Sep 23 '11 at 13:38