Convert complex XML to Cache Object

Primary tabs

Caché, SOAP

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!

  • 0
  • 0
  • 656
  • 7

Replies

The return value of your WebService has to be  of type
 ServiceTestPrd.Request.ReqPatInfo 

Method GetPatInfo(QueryInfo As %Stream.GlobalCharacter) As ServiceTestPrd.Request.ReqPatInfo  [ WebMethod ]

and you terminate with your object.

quit reqObj 

it just works with local variables in memory.

I referred to this:

USER>s ^rcc=sbJSON
USER>s x=^rcc
USER>zw x
x="6@%Stream.FileCharacter"
 
USER>d x.%New()

D x.%New()
^
<INVALID OREF>
USER>

correct!  this is just a string looking like an oref, but no oref

The error message tells you what the problem is. It claims there is no end tag for CardType. If you look closely, you'll see that there is a space between "</" and "CardType>". Remove that, and the message will parse correctly. (Kudos for giving complete information and copy/pasting instead of retyping!)

 s ^TMPPRD=reqObj

That won't work. Global can store object serialization or some property value.