parsing xml to list of object issue
hi,
1. Created a class(test) and added a classmethod(checkdata).
2. Assigned a object with xml.
3. Created a new class for response and initialized in classmethod(checkdata).
4. Created a new class for request parsing with list of object parameter.
5. While parsing xml in request for list of object, the result count is "0". But the xml has value for "2" object list.
6. XML has follow:
<Request>
<party>
<to name=""mohan"" address1=""India"" />
<to name=""sujay"" address1=""USA" />
</party>
</Request>Comments
Please add some examples of code.
Are you using correlate? or how are you parsing it to the object? would you put some more details of your approach, as there are many ways to do so.
Without your code we cannot guess what can cause the error.
Anyway, this is en example which works. According to your request/response I think you are talking about web service, therefore I created simple Caché WebService classes:
{
Property to As list Of tv.to(XMLPROJECTION = "ELEMENTREF");
}
{
Property name As %String(XMLPROJECTION = "ATTRIBUTE");
Property address1 As %String(XMLPROJECTION = "ATTRIBUTE");
}
{
Parameter SERVICENAME = "PartyService";
Parameter NAMESPACE = "http://tempuri.org";
Parameter USECLASSNAMESPACES = 1;
Method CheckData(party As tv.party) As %Integer [ WebMethod ]
{
Quit party.to.Count()
}
}
Then I created SOAP web client using SoapUI and sent following request with 3 'to' items:
<soapenv:Header/>
<soapenv:Body>
<s:CheckData>
<s:party>
<s:to name="mohan" address1="India"/>
<s:to name="sujay" address1="USA"/>
<s:to name="tomas" address1="Europe"/>
</s:party>
</s:CheckData>
</soapenv:Body>
</soapenv:Envelope>
And I received the correct response:
<SOAP-ENV:Body>
<CheckDataResponse xmlns="http://tempuri.org">
<CheckDataResult>3</CheckDataResult>
</CheckDataResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
If you send as your code, we can check what is not working as expected.
Without your code we cannot guess what can cause the error. If you send us example of your code, we can check what is not working as expected.
Anyway, this is en example which works. According to your request/response I think you are talking about web service, therefore I created simple Caché WebService classes:
Class tv.party Extends (%RegisteredObject, %XML.Adaptor){Property to As list Of tv.to(XMLPROJECTION = "ELEMENTREF");}Class tv.to Extends (%RegisteredObject, %XML.Adaptor){Property name As %String(XMLPROJECTION = "ATTRIBUTE");Property address1 As %String(XMLPROJECTION = "ATTRIBUTE");}Class tv.PartyService Extends %SOAP.WebService [ ProcedureBlock ]{Parameter SERVICENAME = "PartyService";Parameter NAMESPACE = "http://tempuri.org";Parameter USECLASSNAMESPACES = 1;Method CheckData(party As tv.party) As %Integer [ WebMethod ]{Quit party.to.Count()}}Then I created SOAP web client using SoapUI and sent following request with 3 'to' items:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s="http://tempuri.org">
<soapenv:Header/>
<soapenv:Body>
<s:CheckData>
<s:party>
<s:to name="mohan" address1="India"/>
<s:to name="sujay" address1="USA"/>
<s:to name="tomas" address1="Europe"/>
</s:party>
</s:CheckData>
</soapenv:Body>
</soapenv:Envelope>And I received the correct response:
<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>
<CheckDataResponse xmlns="http://tempuri.org">
<CheckDataResult>3</CheckDataResult>
</CheckDataResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>