You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by Tao Yang <ty...@simdesk.com> on 2006/02/21 20:02:17 UTC
AxisC++ 1.5 fail retrieve string arrays in SOAP message?
Hi,
Again with my Axis C++ 1.5 client running against the Axis JAVA 1.3
server experiment:
I have a webservice has interface : String[] search(String getIgnored)
the java client handle it perfectly by the way.
My c++ client is a bit funky though. The stub generated has following
code (I add some
debuging output):
xsd__string_Array Search::search(xsd__string Value0)
{
xsd__string_Array RetArray = {NULL, 0};
const char* pcCmplxFaultName;
try
{
if (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER))
return RetArray;
if (NULL==m_pCall->getTransportProperty("SOAPAction",false))
{
m_pCall->setTransportProperty(SOAPACTION_HEADER , "");
}
m_pCall->setSOAPVersion(SOAP_VER_1_1);
m_pCall->setOperation("search", "http://ws.search.simdesk.com");
applyUserPreferences();
m_pCall->addParameter((void*)Value0, "criteria", XSD_STRING);
if (AXIS_SUCCESS == m_pCall->invoke())
{
if(AXIS_SUCCESS == m_pCall->checkMessage("searchResponse",
"http://ws.search.simdesk.com"))
{
// tyang changed following line - it complains about
type conversion is invalid
//RetArray =
(xsd__string_Array&)m_pCall->getBasicArray(XSD_STRING, "searchReturn", 0);
Axis_Array arr = m_pCall->getBasicArray(XSD_STRING,
"searchReturn", 0);
xsd__string_Array sarr = { (xsd__string *) arr.m_Array,
arr.m_Size };
RetArray.m_Array = (xsd__string *) arr.m_Array;
RetArray.m_Size = arr.m_Size;
std::cout << "result.size = " << RetArray.m_Size << endl;
std::cout << "result: ";
for (int i = 0; i < RetArray.m_Size; i++)
{
std::cout << RetArray.m_Array[i] << ";
"; std::cout << endl;
}
}
m_pCall->unInitialize();
return RetArray;
}
catch(AxisException& e)
{
int iExceptionCode = e.getExceptionCode();
if(AXISC_NODE_VALUE_MISMATCH_EXCEPTION != iExceptionCode)
{
throw SoapFaultException(e);
}
ISoapFault* pSoapFault = (ISoapFault*)
m_pCall->checkFault("Fault","http://172.16.53.33:8080/simdesk/services/Search"
);
if(pSoapFault)
{
m_pCall->unInitialize();
throw SoapFaultException(e);
}
else throw;
}
}
Plus, the SOAPMonitor reporting following request:
<?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:search xmlns:ns1="http://ws.search.simdesk.com">
<criteria xsi:type="xsd:string">asdr</criteria>
</ns1:search>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
And following response:<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:searchResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://ws.search.simdesk.com">
<searchReturn soapenc:arrayType="soapenc:string[6]"
xsi:type="soapenc:Array"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<searchReturn xsi:type="soapenc:string">eqre.pdf</searchReturn>
<searchReturn xsi:type="soapenc:string">another.txt</searchReturn>
<searchReturn xsi:type="soapenc:string"></searchReturn>
<searchReturn xsi:type="soapenc:string">~/blah.h</searchReturn>
<searchReturn xsi:type="soapenc:string">asdf</searchReturn>
<searchReturn xsi:type="soapenc:string" xsi:nil="true"/>
</searchReturn>
</ns1:searchResponse>
</soapenv:Body>
</soapenv:Envelope>
What have I done wrong? :-(
Thanks for any help or advice in advance!
Tao
Re: AxisC++ 1.5 fail retrieve string arrays in SOAP message?
Posted by Adrian Dick <ad...@uk.ibm.com>.
Hi,
There were still some outstanding issues with arrays at the release of Axis
C++ 1.5. There has since been a lot of work in improving the design and
workings of arrays, which is available in the 1.6 nightly builds - you may
wish to try these to see if your problems have already been resolved.
Regards,
Adrian
_______________________________________
Adrian Dick (adrian.dick@uk.ibm.com)
Tao Yang <ty...@simdesk.com> wrote on 21/02/2006 23:52:33:
> Just in case someone else may want to know my lesson here.
>
> It turns out this is happening because I always return a array whose
> last item is null - I was paranoid before I dig into Axis C++ and afraid
> of it won't know the size of the array so that that null is put in as
> boundary indicator. However, nicely the Axis C++ does return the array
> size; but fail to cope with my "null" boundary indicator and thought
> error has happened.
>
> This does raise a question though: why Axis C++ can't handle a "null"
> item? the java version process this nicely by the way.
>
> cheers,
> Tao
>
> Tao Yang wrote:
>
> > Oops, I forget to say. Even the valid response is observed through
> > the SOAPMonitor, the c++ client code is always reporting:
> > "result.size = 0"
> > What could be preventing it extract the strings from the message?
> >
> > Thanks,
> > Tao
> >
> >>
> >
Re: AxisC++ 1.5 fail retrieve string arrays in SOAP message?
Posted by Tao Yang <ty...@simdesk.com>.
Just in case someone else may want to know my lesson here.
It turns out this is happening because I always return a array whose
last item is null - I was paranoid before I dig into Axis C++ and afraid
of it won't know the size of the array so that that null is put in as
boundary indicator. However, nicely the Axis C++ does return the array
size; but fail to cope with my "null" boundary indicator and thought
error has happened.
This does raise a question though: why Axis C++ can't handle a "null"
item? the java version process this nicely by the way.
cheers,
Tao
Tao Yang wrote:
> Oops, I forget to say. Even the valid response is observed through
> the SOAPMonitor, the c++ client code is always reporting:
> "result.size = 0"
> What could be preventing it extract the strings from the message?
>
> Thanks,
> Tao
>
>>
>
Re: AxisC++ 1.5 fail retrieve string arrays in SOAP message?
Posted by Tao Yang <ty...@simdesk.com>.
Oops, I forget to say. Even the valid response is observed through
the SOAPMonitor, the c++ client code is always reporting:
"result.size = 0"
What could be preventing it extract the strings from the message?
Thanks,
Tao
Tao Yang wrote:
> Hi,
>
> Again with my Axis C++ 1.5 client running against the Axis JAVA 1.3
> server experiment:
> I have a webservice has interface : String[] search(String getIgnored)
> the java client handle it perfectly by the way.
>
> My c++ client is a bit funky though. The stub generated has following
> code (I add some
> debuging output):
> xsd__string_Array Search::search(xsd__string Value0)
> {
> xsd__string_Array RetArray = {NULL, 0};
> const char* pcCmplxFaultName;
> try
> {
> if (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER))
> return RetArray;
> if (NULL==m_pCall->getTransportProperty("SOAPAction",false))
> {
> m_pCall->setTransportProperty(SOAPACTION_HEADER , "");
> }
> m_pCall->setSOAPVersion(SOAP_VER_1_1);
> m_pCall->setOperation("search", "http://ws.search.simdesk.com");
> applyUserPreferences();
> m_pCall->addParameter((void*)Value0, "criteria", XSD_STRING);
> if (AXIS_SUCCESS == m_pCall->invoke())
> {
> if(AXIS_SUCCESS == m_pCall->checkMessage("searchResponse",
> "http://ws.search.simdesk.com"))
> {
> // tyang changed following line - it complains about
> type conversion is invalid
> //RetArray =
> (xsd__string_Array&)m_pCall->getBasicArray(XSD_STRING, "searchReturn",
> 0);
> Axis_Array arr = m_pCall->getBasicArray(XSD_STRING,
> "searchReturn", 0);
> xsd__string_Array sarr = { (xsd__string *) arr.m_Array,
> arr.m_Size };
> RetArray.m_Array = (xsd__string *) arr.m_Array;
> RetArray.m_Size = arr.m_Size;
> std::cout << "result.size = " << RetArray.m_Size << endl;
> std::cout << "result: ";
> for (int i = 0; i < RetArray.m_Size; i++)
> {
> std::cout << RetArray.m_Array[i] << ";
> "; std::cout << endl;
> }
> }
> m_pCall->unInitialize();
> return RetArray;
> }
> catch(AxisException& e)
> {
> int iExceptionCode = e.getExceptionCode();
> if(AXISC_NODE_VALUE_MISMATCH_EXCEPTION != iExceptionCode)
> {
> throw SoapFaultException(e);
> }
> ISoapFault* pSoapFault = (ISoapFault*)
>
> m_pCall->checkFault("Fault","http://172.16.53.33:8080/simdesk/services/Search"
> );
> if(pSoapFault)
> {
> m_pCall->unInitialize();
> throw SoapFaultException(e);
> }
> else throw;
> }
> }
>
> Plus, the SOAPMonitor reporting following request:
> <?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:search xmlns:ns1="http://ws.search.simdesk.com">
> <criteria xsi:type="xsd:string">asdr</criteria>
> </ns1:search>
> </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
>
> And following response:<?xml version="1.0" encoding="UTF-8"?>
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <soapenv:Body>
> <ns1:searchResponse
> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:ns1="http://ws.search.simdesk.com">
> <searchReturn soapenc:arrayType="soapenc:string[6]"
> xsi:type="soapenc:Array"
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
> <searchReturn xsi:type="soapenc:string">eqre.pdf</searchReturn>
> <searchReturn xsi:type="soapenc:string">another.txt</searchReturn>
> <searchReturn xsi:type="soapenc:string"></searchReturn>
> <searchReturn xsi:type="soapenc:string">~/blah.h</searchReturn>
> <searchReturn xsi:type="soapenc:string">asdf</searchReturn>
> <searchReturn xsi:type="soapenc:string" xsi:nil="true"/>
> </searchReturn>
> </ns1:searchResponse>
> </soapenv:Body>
> </soapenv:Envelope>
>
> What have I done wrong? :-(
>
> Thanks for any help or advice in advance!
> Tao
>
>
>