Search code examples
xmlweb-servicessoapintersystems-cacheintersystems

Correct XML to send for cache web service SOAP header


I created a simple header class:

Class Sample.Headers Extends %SOAP.Header
{
    Parameter NAMESPACE = "http://tempuri.org";
    Property UserName As %String;
}

In the web service I made sure to set the correct namespace in the SOAPHEADERS parameter:

Parameter SOAPHEADERS = "UserName:Sample.Headers";

I send the following XML using SoapUI:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org">
   <soapenv:Header>
       <tem:UserName>This is the header</tem:UserName>
   </soapenv:Header>
   <soapenv:Body>
      <tem:Test>
         <!--Optional:-->
         <tem:argAge>10</tem:argAge>
      </tem:Test>
   </soapenv:Body>
</soapenv:Envelope>

I get the following error:

ERROR #6254: Tag expected, XML input, This is the header, is not in proper format as child of UserName (ending at line 3 character 18).

What is the correct format for the XML so that UserName is set correctly?


Solution

  • Just needed to change:

    Property UserName As %String;
    

    to

    Property UserName As %String(XMLPROJECTION = "CONTENT", MAXLEN = 50);