Loading ...
Sorry, an error occurred while loading the content.

Suppressing xsi:nil for methods with no parameters

Expand Messages
  • balajisrinivasan00
    Hi Everyone I am trying to get a SOAP::Lite client working with a GSOAP web service. I want to enable strict parsing on the GSOAP side so that I can catch
    Message 1 of 1 , Apr 17 1:24 PM
    • 0 Attachment
      Hi Everyone
      I am trying to get a SOAP::Lite client working with a GSOAP web
      service. I want to enable strict parsing on the GSOAP side so that I
      can catch errors before the request reaches my code.

      For web service methods that take in no parameters, SOAP::Lite encodes
      a xsi:nil="true" attribute in the soap body. For example if the
      request is doStuff, the XML looks as follows:

      <?xml version="1.0" encoding="UTF-8"?><soap:Envelope
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
      soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
      <namesp38:doStuff xsi:nil="true" xmlns:namesp38="http://foo.com/bar/"/>
      </soap:Body>
      </soap:Envelope>

      Now this causes GSOAP to error out saying xsi:nil is not allowed. I
      believe GSOAP is doing the right thing. The method name (here doStuff)
      cannot be nil. So SOAP::Lite should not be setting its xsi:nil
      attribute. The error is in the envelope method:
      The value of body should be set only if parameters is defined. So we
      need to change the code in line 1402 from:
      $body->set_value(SOAP::Utils::encode_data($parameters ?
      \$parameters : ()))
      if $body;

      to:

      $body->set_value(SOAP::Utils::encode_data($parameters ?
      \$parameters : ()))
      if $body && $parameters;

      Can anyone comment on this fix?
      Thanks
      Balaji
    Your message has been successfully submitted and would be delivered to recipients shortly.