Question
· Jan 4, 2018

Convert complex XML to Cache Object

I use SoapUI 5.4.0 test Cache development web service, the parameters I need to send through SoapUI is as follows:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:GetPatInfo>
         <!--Optional:-->
         <tem:QueryInfo>
         <![CDATA[
<Request>
    <CardNo>100000220002</CardNo>
    <CardType></ CardType >
</Request>
]]>
</tem:QueryInfo>
      </tem:GetPatInfo>
   </soapenv:Body>
</soapenv:Envelope>

I have a Cache object:

Class ServiceTestPrd.Request.ReqPatInfo Extends (%RegisteredObject, %XML.Adaptor)
{

Property CardNo As %String;

Property CardType As %String;

}

My web service class is:

/// ServiceTestPrd.PrdServiceTest
Class ServiceTestPrd.PrdServiceTest Extends %SOAP.WebService [ ProcedureBlock ]
{

Parameter SERVICENAME = "PrdServiceTest";

Parameter NAMESPACE = "http://tempuri.org";

Parameter USECLASSNAMESPACES = 1;

Method GetPatInfo(QueryInfo As %Stream.GlobalCharacter) As %Stream.GlobalCharacter [ WebMethod ]
{
    s reader = ##class(%XML.Reader).%New()
    s status = reader.OpenStream(QueryInfo)
    d reader.Rewind()
    Do reader.CorrelateRoot("ServiceTestPrd.Request.ReqPatInfo")
    s reqObj = ""
    While (reader.Next(.tMessage,.status)) {
        s reqObj=tMessage
    }
    s ^TMPPRD=reqObj
    
    
    q QueryInfo
}

}

After sending the request using SoapUI, the returned message is:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.w3.org/2001/XMLSchema">
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Client</faultcode>
         <faultstring>internal server error</faultstring>
         <detail>
            <error xmlns="http://tempuri.org">
               <text>error #6301: SAX XML Analyzer error: expected end of tag 'CardType' while processing Anonymous Stream at line 3 offset 14</text>
            </error>
         </detail>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

How do I get the value of CardNo and CardType? thank you!

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