p rd · 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="" xmlns:tem="">
    <CardType></ CardType >

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 = "";


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="" xmlns:xsi="" xmlns:s="">
         <faultstring>internal server error</faultstring>
            <error xmlns="">
               <text>error #6301: SAX XML Analyzer error: expected end of tag 'CardType' while processing Anonymous Stream at line 3 offset 14</text>

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

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

The return value of your WebService has to be  of type

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

and you terminate with your object.

quit reqObj 

thank you !

it just works with local variables in memory.

I referred to this:

USER>s ^rcc=sbJSON
USER>s x=^rcc
USER>zw x
USER>d x.%New()

D x.%New()

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.