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 "Gavin M. Bell" <cu...@llnl.gov> on 2005/09/07 08:33:50 UTC

Re: Hello Word from C++ client to Java service returns "(null)", huh??

Okay...
So After re-building everything, thinking that perhaps there were issues 
with regards to the codebase and any stray interactions, I was able to 
again run my WSDL2Ws on my wsdl and get my generated code.  My lil 
client calls a simple "hello world" echo method.

This is what I get on the command line (same as the original post)
[output from my program]
 Using service at http://localhost:1596/NaracWS/services/HelloModel

 Instantiating remote endpoint stub... [OK]
 attempting to send the string [cpp test]
*Before remote call - Result: <no-result>
*After  remote call - Result: (null)

Notice that the result I get back is set to "(null)" somewhere!

My web service's logs say that it is behaving just fine, and responding 
correctly, corroborated by my java ws client can speak to my service 
without a problem.

I have attached the trace from the TCPMON program...
It looks as through the right XML is coming in from the service. (check 
the trace and double check me on that).

So, I am thinking the only problem would be deep in the axis code.  
However, this all seems silly.  This is a simple hello world echo 
service passing a string and getting a string.  This had to have been 
done before from a C++ client to a SERVICE


Adrian Dick wrote:

>Hi,
>
>Would it be possible to capture the SOAP request and response?   You can
>use tcpmonitor, which is part of axis.jar, to do this.
>Also, it would be useful if you can provide your WSDL, so we can confirm
>the message is as expected, and the stubs are being correctly generated.
>
>Adrian
>_______________________________________
>Adrian Dick (adrian.dick@uk.ibm.com)
>
>
>"Gavin M. Bell" <cu...@llnl.gov> wrote on 24/08/2005 17:17:34:
>
>  
>
>>Hello Gentle-people,
>>
>>I have been going through the exercise of getting axis-c++ to work.
>>I am using the axis-c-1.5.0-linux-bin distribution.  I have created a
>>Java 'helloworld' echo service.
>>A simple service, you pass it a string and it returns to you the same
>>string prepended with an ack string.
>>
>>I used axis to build the stub and header files for my serice.  I then
>>run my serice.... the java axis service gets the string (as evidenced by
>>the log output) and then returns.  The client returns "(null)".
>>
>>Why is that?  Why does it not return the echo string sent by the service?
>>I have been reading the list and have set multiRef to false in the axis
>>service-config.wsdd file:
>>
>> <globalConfiguration>
>>  <parameter name="adminPassword" value="admin"/>
>>  <parameter name="attachments.implementation"
>>value="org.apache.axis.attachments.AttachmentsImpl"/>
>>  <parameter name="sendXsiTypes" value="true"/>
>>  <parameter name="sendMultiRefs" value="false"/>
>>  <parameter name="sendXMLDeclaration" value="true"/>
>>  <requestFlow>
>>   <handler type="java:org.apache.axis.handlers.JWSHandler">
>>    <parameter name="scope" value="session"/>
>>   </handler>
>>   <handler type="java:org.apache.axis.handlers.JWSHandler">
>>    <parameter name="scope" value="request"/>
>>    <parameter name="extension" value=".jwr"/>
>>   </handler>
>>  </requestFlow>
>> </globalConfiguration>
>>
>>I am using resin-3.0.14 as my service container...
>>
>>My service side code (java) is:
>>...
>>    public java.lang.String request( java.lang.String msg ) {
>>        if(msg == null) msg = "<noname>";
>>        System.out.println("some thing: "+msg);
>>        return "This is the hello world! - \""+msg+"\"";
>>    }
>>...
>>
>>My client side code (c++) is:
>>...
>>int
>>main (int argc, char *argv[])
>>{
>>  char endpoint[256];
>>  char original[256];
>>  const char *server = "localhost";
>>  const char *port = "1595";
>>  const char *inputString = "<test-echo-string>";
>>  const char *resultString = "<no-result>";
>>
>>  // Set default service URL
>>  sprintf (endpoint,
>>    
>>
>"http://localhost:1595/NaracWS/services/HelloModel");
>  
>
>>  sprintf (original, endpoint);
>>
>>  try{
>>      if (argc < 1)
>>    {
>>      usage (argv[0], endpoint);
>>      return 2;
>>    }
>>
>>      cout << endl << " Using service at " << endpoint << endl << endl;
>>      cout << "Instantiating remote endpoint stub... ";
>>      HelloModel ws(endpoint);
>>      cout << "[OK]" << endl;
>>
>>      cout << "attempting to send the string [cpp test]" <<endl;
>>      printf ("Before remote call - Result: %s\n", resultString);
>>      resultString = ws.request("cpp test");
>>      printf ("After  remote call - Result: %s\n", resultString);
>>      }
>>  catch (AxisException & e){printf ("\nException : %s\n", e.what ());}
>>  catch (exception & e){printf ("\nUnknown exception has occured\n");}
>>  catch (...) { printf ("\nUnknown exception has occured\n");}
>>  return 0;
>>}
>>
>>C++ client output:
>>
>> Using service at http://localhost:1595/NaracWS/services/HelloModel
>>
>>Instantiating remote endpoint stub... Warning - The WSDDFilePath file
>>(/home/obj/etc/server.wsdd) in the AXISCPP.CONF file does not exist.
>>[OK]
>>attempting to send the string [cpp test]
>>Before remote call - Result: <no-result>
>>After  remote call - Result: (null)
>>
>>To build it:
>> g++ *.cpp -I/home/cue/workbench/axis-c-1.5.0-linux-bin/include
>>-L/home/cue/workbench/axis-c-1.5.0-linux-bin/lib/ -ldl -l axis_client
>>-ohello_echo
>>
>>I am at my wit's end.  Please, any help would be appreciated.
>>(I have attached the generated stub and header file)
>>
>>
>>--
>>
>>
>>------
>>   Gavin M. Bell
>>   Computer Science Research Scientist
>>   Computing Applications and Research Dept.
>>   Lawrence Livermore National Labs
>>   L-103
>>   cue@llnl.gov
>>-------
>>
>>"I'm trying real hard to be the shepherd."
>>            -Samuel Jackson (Pulp Fiction)
>>
>>/*
>> * This file was auto-generated by the Axis C++ Web Service
>>Generator (WSDL2Ws)
>> * This file contains Client Stub implementation for remote web service.
>> */
>>
>>#include "HelloModel.hpp"
>>
>>#include <axis/AxisWrapperAPI.hpp>
>>#include <string.h>
>>
>>using namespace std;
>>
>> HelloModel::HelloModel(const char* pchEndpointUri,
>>AXIS_PROTOCOL_TYPE eProtocol)
>>:Stub(pchEndpointUri, eProtocol)
>>{
>>}
>>
>>HelloModel::HelloModel()
>>:Stub(" ", APTHTTP1_1)
>>{
>>
>>    
>>
>m_pCall->setEndpointURI("http://localhost:1595/NaracWS/services/HelloModel
>  
>
>>");
>>}
>>
>>HelloModel::~HelloModel()
>>{
>>}
>>
>>
>>/*Methods corresponding to the web service methods*/
>>
>>/*
>> * This method wrap the service method request
>> */
>>xsd__string HelloModel::request(xsd__string Value0)
>>{
>>   xsd__string Ret;
>>   memset(&Ret,0,sizeof(xsd__string));
>>   const char* pcCmplxFaultName;
>>   try
>>   {
>>      if (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER))
>>         return Ret;
>>   if (NULL==m_pCall->getTransportProperty("SOAPAction",false))
>>   {
>>      m_pCall->setTransportProperty(SOAPACTION_HEADER , "");
>>   }
>>      m_pCall->setSOAPVersion(SOAP_VER_1_1);
>>      m_pCall->setOperation("request", "http://localhost:
>>1595/NaracWS/services/HelloModel");
>>      applyUserPreferences();
>>      m_pCall->addParameter((void*)Value0, "msg", XSD_STRING);
>>      if (AXIS_SUCCESS == m_pCall->invoke())
>>      {
>>         if(AXIS_SUCCESS == m_pCall->checkMessage("requestResponse", "
>>http://localhost:1595/NaracWS/services/HelloModel"))
>>         {
>>            Ret = m_pCall->getElementAsString("requestReturn", 0);
>>         }
>>      }
>>   m_pCall->unInitialize();
>>      return Ret;
>>   }
>>   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://localhost:
>>1595/NaracWS/services/HelloModel" );
>>      if(pSoapFault)
>>      {
>>         m_pCall->unInitialize();
>>         throw SoapFaultException(e);
>>      }
>>      else throw;
>>   }
>>}
>>
>>/*
>> * This file was auto-generated by the Axis C++ Web Service
>>Generator (WSDL2Ws)
>> * This file contains Client Stub Class for remote web service
>> */
>>
>>#if !defined(__HELLOMODEL_CLIENTSTUB_H__INCLUDED_)
>>#define __HELLOMODEL_CLIENTSTUB_H__INCLUDED_
>>
>>#include <axis/client/Stub.hpp>
>>#include <axis/SoapFaultException.hpp>
>>#include <axis/ISoapFault.hpp>
>>AXIS_CPP_NAMESPACE_USE
>>
>>class HelloModel :public Stub
>>{
>>public:
>>   STORAGE_CLASS_INFO HelloModel(const char* pchEndpointUri,
>>AXIS_PROTOCOL_TYPE eProtocol=APTHTTP1_1);
>>   STORAGE_CLASS_INFO HelloModel();
>>public:
>>   STORAGE_CLASS_INFO virtual ~HelloModel();
>>public:
>>   STORAGE_CLASS_INFO xsd__string request(xsd__string Value0);
>>};
>>
>>#endif /* !defined(__HELLOMODEL_CLIENTSTUB_H__INCLUDED_)*/
>>    
>>
>
>
>  
>

-- 


------
   Gavin M. Bell
   Computer Science Research Scientist
   Computing Applications and Research Dept.
   Lawrence Livermore National Labs
   L-103
   cue@llnl.gov
-------

"I'm trying real hard to be the shepherd."
				-Samuel Jackson (Pulp Fiction)