axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nadir Amra <a...@us.ibm.com>
Subject Re: problems using getAnyObject() -- please help
Date Fri, 26 Oct 2007 14:48:17 GMT
Vineet,

First I want to make sure you are using the latest code from SVN and not 
1.6b. 

I have a lot on my plate but I can take a look sometime next week. 

Assuming you are, and to expedite the debugging I will need to do, please 
attach a complete simple client example....since you already showed the a 
SOAP response I do not need that. 


Nadir K. Amra


"Aggarwal, Vineet" <Vineet.Aggarwal@mantas.com> wrote on 10/26/2007 
09:29:49 AM:

> Hi all,
> 
> I have been struggling with this for days.  I?ve finally reached the
> point where I can?t get any further and need to reach out for help.
> 
> I need to be able to work directly with the XML contents of the SOAP
> request rather than going through one of the objects created in the 
> server side stubs.  The only way I?ve discovered to be able to do 
> this is by using IWrapperSoapDeSerializer::getAnyObject().  I 
> thought this was the appropriate method because of the comments in 
> the header:  ?Will deserialize the next available SOAP element and 
> all child elements.?
> 
> I will walk through some examples of what I?ve tried in an attempt 
> to properly explain the issues I am running into.  Note that these 
> are just code snippets, I am leaving some of the obvious code out, 
> and you can pretty much assume that I?ve set things up properly. 
> Here is what I did with my first attempt at printing out the XML:
> 
> AnyType *pV0 = pIHSDZ->getAnyObject();
> for (int i = 0; i < pV0->_size; i++)
> {
>   cout << pV0->_array[i];
> }
> 
> This only printed out part of the XML.  As such, I realized that I 
> needed to make multiple calls to getAnyObject() in order to get the 
> next elements, so I tried this:
> 
> AnyType *pV0 = pIHSDZ->getAnyObject();
> while (pV0 != NULL)
> {
>   for (int i = 0; i < pV0->_size; i++)
>   {
>     cout << pV0->_array[i];
>   }
>   pV0 = pIHSDZ->getAnyObject();
> }
> 
> This resulted in a segmentation fault, which after reading multiple 
> posts online, I discovered that it was because getAnyObject() will 
> never return NULL, so we end up making calls to it even after no 
> further objects remain, resulting in the segmentation fault.  This 
> is where my confusion comes in.  If I ended up getting all the XML 
> and then made a call to getAnyObect() and it then seg faulted, I 
> would completely understand.  However, it seg faults after I only 
> get part of the XML (leading me to believe that further calls to 
> getAnyObect() actually SHOULD return something).
> 
> Let me illustrate this with an example.  Say the XML contents of the
> SOAP message is the following:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <mantas:MantasAlertData 
>   xmlns:mantas="http://namespaces.mantas.com/MAD"
>   xmlns:action="http://namespaces.mantas.com/MAD/Action"
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xsi:schemaLocation="http://namespaces.mantas.com/MAD 
MantasAlertData.xsd"
> > 
>   <AlertData>
>     <AlertContext>
>       <FocusTypeCode>EN</FocusTypeCode>
>     </AlertContext> 
>     <Matches>
>       <MatchInformation> 
>         <MatchedDataRecords>
>           <MatchedRecord>
>             <RecordType>EXTERNAL_ENTITY</RecordType>
>             <Relationship>Matched</Relationship>
>             <MatchedData>
>               <Attribute name="EXTRL_NTITY_TYPE_CD" 
> type="string">NM</Attribute> 
>             </MatchedData>
>           </MatchedRecord> 
>         </MatchedDataRecords> 
>       </MatchInformation>
>     </Matches> 
>   </AlertData> 
> </mantas:MantasAlertData>
> 
> If you run my above code, this is what will get output to the 
> consoled before the segmentation fault:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <mantas:MantasAlertData 
>   xmlns:mantas="http://namespaces.mantas.com/MAD"
>   xmlns:action="http://namespaces.mantas.com/MAD/Action"
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xsi:schemaLocation="http://namespaces.mantas.com/MAD 
MantasAlertData.xsd"
> > 
>   <AlertData>
>     <AlertContext>
>       <FocusTypeCode>EN</FocusTypeCode>
>     </AlertContext> 
>     <Matches>
>       <MatchInformation> 
>         <MatchedDataRecords>
>           <MatchedRecord>
>             <RecordType>EXTERNAL_ENTITY</RecordType/>
>             <Relationship>Matched</Relationship>
>             <MatchedData>
> 
> Note that there a few things wrong with this.  First of all, why 
> doesn?t the rest get printed out?  If there is more data, why does 
> it seg fault?  I even put in a counter to check how many times I go 
> through the loop before it seg faults, and limited the loop to that 
> number?that solves the seg fault issue, but I still don?t get all 
> the data.  Secondly, the data is somewhat corrupted:  I don?t know 
> where the extra slashes have come from (e.g. </RecordType/> instead 
> of </RecordType>).  The same happens with the reverse situation as 
> well.  That is, if I try to feed some XML through an AnyType object 
> back into the response, it also gets corrupted.  For example, the 
> following code:
> 
> 
pIWSSZ->createSoapMethod("PrioritizeAlertResponse","http://namespaces.tech.com
> ");
> try
> {
>   AnyType *pAny = new AnyType();
>   pAny->_size = 1;
>   pAny->_array = new char*[1];
>   pAny->_array[0] = "<AlertData></AlertData>";
> 
>   return pIWSSZ->addOutputAnyObject(pAny);
> }
> 
> Produces the following response:
> 
> <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope 
xmlns:SOAP-ENV="
> http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.
> org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <SOAP-ENV:Body>
> <ns1:PrioritizeAlertResponse xmlns:ns1="http://namespaces.mantas.com">
> <AlertData/></ns1:PrioritizeAlertResponse>
> </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
> 
> Whereas I am expecting:
> 
> <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope 
xmlns:SOAP-ENV="
> http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.
> org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <SOAP-ENV:Body>
> <ns1:PrioritizeAlertResponse xmlns:ns1="http://namespaces.mantas.com">
> <AlertData></AlertData></ns1:PrioritizeAlertResponse>
> </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
> 
> Does anybody have any idea why I am experiencing the above issues? 
> If not, is there any other way to directly access the XML?  I know 
> this is a lot to digest, but I could REALLY use some help.  I am 
> working on a solution for which I centered the web services around 
> Axis for C++, and if I can?t get it to work, I am basically screwed.
> I?m not sure I have the time to rearchitect some other solution (i.
> e. using Axis for Java and calling the C++ code through JNI or 
something).
> 
> Thanks in advance for any help, it is much appreciated!
> 
> Vineet

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org


Mime
View raw message