axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Souther <bsout...@fwdco.com>
Subject Re: AW: Getting an axis c++ client to talk with an axis java/servlet app.
Date Tue, 01 Jun 2004 18:56:08 GMT
There is no second param. WSDL2Ws incorrectly set the return as a second input 
parameter.  I was able to get around this by recoding the results from the 
WSDL2Ws.

The WSDL says "capitalizeResponse".
<wsdl:output name="capitalizeResponse">

Thank you,
-Ben





On Tuesday 01 June 2004 02:36 pm, Bochnak Filip wrote:
> Hi Ben
>
> I think that your second param, should be changed to "capitalizeReturn",
> (instead of "capitalizeResponse" )
> Have a look at your wsdl file you will find the correct variable name.
>
>
>
> 		if(AXIS_SUCCESS ==
> m_pCall->CheckMessage("capitalizeResponse",
> "http://192.168.0.103:8888/file_manager/services/EchoCaps")){
> 			return
> m_pCall->GetElementAsString("capitalizeResponse",
> "http://192.168.0.103:8888/file_manager/service/EchoCaps");
> 		}
>
>
> Hope it helps you
> Cu Phil
>
> p.s. if it didn┬┤t help you, so you could try maybe to change the "printfs"
> to "cout" (<iostream>)
>
>
>
> -----Urspr├╝ngliche Nachricht-----
> Von: Ben Souther [mailto:bsouther@fwdco.com]
> Gesendet: Dienstag, 1. Juni 2004 20:28
> An: Apache AXIS C User List
> Betreff: Getting an axis c++ client to talk with an axis java/servlet
> app.
>
>
> Hello,
>
> I just moved this thread over from the axis-users list (the whole thread is
> in
> the footer of this message).  I apologize for the appearance of a cross
> post.
>
> I'm trying to write a small client in c++ that can communicate with some
> webservices already writtin in Java, hosted on a tomcat/axis server.
>
> I've re-worked the code that was generated by WSDL2Ws to get around the
> extra
> parameter issue and have posted the code below.  I know that the client is
> making the call to the server and that it is passing the correct
> parameters.
>
> I also know that the server is passing back the correct results (see the
> output captured from tcpmon below) but for some reason, the client hangs
> for
>
> around 10 seconds and then returns with the following message:
> -----------------------------------------------------
> execution break
> m_MsgSize == 0, so return NULL
>
> results: method complete
> Press any key to continue
>
> It then goes on to complete the function.
> -----------------------------------------------------
>
> When I compare the HTTP data (captured with tcpmon, also posted below) with
> the same client written in java, I can see that the java client specifies
> HTTP/1.0. The message is is then returned un-chunked.
>
> The c++ app specifies HTTP/1.1.  and the server returns the message
> "chunked".
>
> I'm reluctant to blame it on the chunking only because the c++ version of
> Axis
> specifies HTTP/1.1 which I don't think it would do if it couldn't handle
> chunking.
>
> If anyone has any advise or pointers, they would be welcome.
> Thanks,
> -Ben
>
>
> =============================================================
> Here is the c++ code after I re-worked the results from calling WSDL2Ws
> =============================================================
> #include "EchoCaps.h"
> #include <axis/server/AxisWrapperAPI.h>
>
> bool CallBase::bInitialized;
> CallFunctions CallBase::ms_VFtable;
>
> //
> // constructor
> //
> EchoCaps::EchoCaps(){
> 	m_pCall = new Call();
> 	m_pCall->SetProtocol(APTHTTP);
>
> m_pCall->SetEndpointURI("http://192.168.0.103:8888/file_manager/services/Ec
>h oCaps");
> }
>
> //
> // destructor
> //
> EchoCaps::~EchoCaps(){
> 	delete m_pCall;
> }
>
> /*
>  * This method wraps the service method "capitalize".
>  */
> char* EchoCaps::capitalize(xsd__string inputString){
>
> 	if (AXIS_SUCCESS != m_pCall->Initialize(CPP_RPC_PROVIDER,
> NORMAL_CHANNEL))
> 		return "failed to initialize" ;
>
> 	m_pCall->SetTransportProperty(SOAPACTION_HEADER ,
> "EchoCaps#capitalize");
> 	m_pCall->SetSOAPVersion(SOAP_VER_1_1);
>
> 		m_pCall->SetOperation("capitalize",
> "http://192.168.0.103:8888/file_manager/services/EchoCaps");
> 	m_pCall->AddParameter((void*)&inputString, "inputString",
> XSD_STRING);
> 	//m_pCall->AddParameter((void*)&Value1, "EchoCaps", XSD_STRING);
>
> 	if (AXIS_SUCCESS == m_pCall->Invoke()){
> 		printf("Invocation went well\n\n");
>
> 		if(AXIS_SUCCESS ==
> m_pCall->CheckMessage("capitalizeResponse",
> "http://192.168.0.103:8888/file_manager/services/EchoCaps")){
> 			return
> m_pCall->GetElementAsString("capitalizeResponse",
> "http://192.168.0.103:8888/file_manager/service/EchoCaps");
> 		}
>
> 		//printf("CheckMessage results: %i\n\n",
> m_pCall->CheckMessage("capitalizeReturn",
> "http://192.168.0.103:8888/file_manager/services/EchoCaps"));
> 	}
>
> 	m_pCall->UnInitialize();
>
> 	return "method complete\n\n";
> }
>
>
> //
> // Main method for testing and debugging only
> //
> void main(){
> 	EchoCaps echoCaps;
>
> 	char* results = echoCaps.capitalize("Input from C++ Client");
> 	printf("results: %s", results);
> }
>
>
>
>
> -------- Original Message --------
> Subject:        Getting the c++ client code to talk to the Java/Servlet
> server
> code...
> Date:   Tue, 1 Jun 2004 08:47:08 -0400
> From:   Ben Souther <bsouther@fwdco.com>
> Reply-To:       axis-user@ws.apache.org
> To:     axis-user@ws.apache.org
> References:     <200405281226.11062.bsouther@fwdco.com>
> <40B7C73C.2000501@cs.indiana.edu> <200406010748.27710.bsouther@fwdco.com>
>
>
>
>
> It appears that, at the moment, the only way to change the Axis c++ client
> to
> send "HTTP/1.0" as the protocol is to change a directive and recompile:
>
>
> ===============================================
> From HttpTransport.cpp:.............................
> ===============================================
>     240 #ifdef HTTP_1_0
>     241   /* As some servers require HTTP 1.0 we temporary define the
>     242    * directive.
>     243    * TODO: can be a WSDL2Ws argument
>     244    */
>     245     m_OutHttpHeaders += m_Url.GetResource() + " HTTP/1.0\r\n";
>     246     /* no support for proxy server yet */
>     247 #else
>     248     /* Use HTTP 1.1; if HTTP 1.0 is required we have to manage with
> setting
>     249      * the properties
>     250      */
>     251     m_OutHttpHeaders += m_Url.GetResource() + " HTTP/1.1\r\n";
>     252     /* no support for proxy server yet */
>     253 #endif
>
>
> I'm still not sure that the problem is due to chunking on the server
> (java/tomcat) end.  I would think that, if the c++ client couldn't handle
> chunked data, that the coders who wrote it would have sent up an HTTP/1.0
> protocol header to begin with.
>
>
> Has anyone had any luck running the c++ client code with the Java/Servlet
> server code?  Any push in the right direction would be greatly appreciated.
>
>
> Thanks
>
> From:
> >Aleksander Slominski <aslom@cs.indiana.edu>
> >
> >
> >
> >axis-user@ws.apache.org
> >
> >
> >
> >Date:
> >Fri, 28 May 2004 18:11:56 -0500
> >the reason is that AXIS C++ client sends HTTP 1.1 request and support in
> >clinet for chunked is then assumed by server (tomcat)::
> >POST /file_manager/services/EchoCaps HTTP/1.1
> >
> >
> >
> >alek
>
> Date:
> Fri, 28 May 2004 18:11:56 -0500
>
> Ben Souther wrote:
> >More Data......
> >
> >
> >
> >
> >Using the tcpmon application, I was able to grab all of the data being
>
> swapped
>
> >between the client and server.
> >
> >
> >
> >
> >For some reason, Axis (server, java) returns the returns the response
> >"chunked" for the C++ Client but not for the Java client.
>
> the reason is that AXIS C++ client sends HTTP 1.1 request and support in
> clinet for chunked is then assumed by server (tomcat)::
> POST /file_manager/services/EchoCaps HTTP/1.1
>
>
>
> alek
>
> >I assume the delay is due to the connection not closing correctly.
> >The C++ app probaly returns after the connection times out???
> >
> >
> >
> >
> >Again, any help is appreciated
> >-Ben
> >
> >
> >
> >
> >Here is the data intercepted with tcpmon:....
> >=================================
> >FROM THE JAVA CLIENT
> >=================================
> >Listen Port: 8888
> >Target Host: 127.0.0.1
> >Target Port: 8080
> >==== Request ====
> >POST /file_manager/services/EchoCaps HTTP/1.0
> >Content-Type: text/xml; charset=utf-8
> >Accept: application/soap+xml, application/dime, multipart/related, text/*
> >User-Agent: Axis/1.1RC2
> >Host: 127.0.0.1
> >Cache-Control: no-cache
> >Pragma: no-cache
> >SOAPAction: ""
> >Content-Length: 473
> >
> >
> >
> >
> ><?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:capitalize
> >soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> >xmlns:ns1="EchoCaps">
> >   <inputString xsi:type="xsd:string">String from the java
> >client</inputString>
> >  </ns1:capitalize>
> > </soapenv:Body>
> ></soapenv:Envelope>
> >
> >
> >
> >
> >
> >==== Response ====
> >HTTP/1.1 200 OK
> >Content-Type: text/xml;charset=utf-8
> >Date: Fri, 28 May 2004 20:17:24 GMT
> >Server: Apache-Coyote/1.1
> >Connection: close
> >
> >
> >
> >
> ><?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:capitalizeResponse
> >       soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> >       xmlns:ns1="EchoCaps">
> >   <EchoCaps xsi:type="xsd:string">STRING FROM THE JAVA CLIENT</EchoCaps>
> >  </ns1:capitalizeResponse>
> > </soapenv:Body>
> ></soapenv:Envelope>
> >
> >
> >
> >
> >
> >
> >
> >===================
> >FROM THE C++ CLIENT..........
> >===================
> >Listen Port: 8888
> >Target Host: 127.0.0.1
> >Target Port: 8080
> >==== Request ====
> >POST /file_manager/services/EchoCaps HTTP/1.1
> >Host: 127.0.0.1
> >Content-Type: text/xml; charset=UTF-8
> >SOAPAction: "EchoCaps#capitalize"
> >Content-Length: 439
> >
> >
> >
> >
> ><?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:capitalize
> >xmlns:ns1="http://192.168.0.103:8888/file_manager/services/EchoCaps">
> >            <inputString xsi:type="xsd:string">Input from C++
> >Client</inputString>
> >        </ns1:capitalize>
> >    </SOAP-ENV:Body>
> ></SOAP-ENV:Envelope>
> >
> >
> >
> >
> >
> >==== Response ====
> >HTTP/1.1 200 OK
> >Content-Type: text/xml;charset=utf-8
> >Transfer-Encoding: chunked
> >Date: Fri, 28 May 2004 20:20:42 GMT
> >Server: Apache-Coyote/1.1
> >
> >
> >
> >
> >20d
> ><?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:capitalizeResponse
> >         soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
>
> xmlns:ns1="http://192.168.0.103:8888/file_manager/services/EchoCaps">
>
> >   <EchoCaps xsi:type="xsd:string">INPUT FROM C++ CLIENT</EchoCaps>
> >  </ns1:capitalizeResponse>
> > </soapenv:Body>
> ></soapenv:Envelope>
> >0
> >
> >On Friday 28 May 2004 12:26 pm, Ben Souther wrote:
> >>Hello,
> >>
> >>
> >>
> >>
> >>I've used the WSDL2Ws tool that ships with Axis C++ to create a simple
> >>client for a java webservice running on axis/tomcat.  The webservice
>
> method
>
> >>takes a string as it's only argument and returns the same string but in
> >>upper case.
> >>
> >>
> >>
> >>
> >>The c++ method that gets generated has an extra input parameter, has a
> >>return type of void, and doesn't seem to work.
> >>
> >>
> >>
> >>
> >>I tried commenting out the line with the second "m_pCall->AddParameter.."
> >>statement.
> >>This improved things a bit.  I can now see that a call is being made.
> >>I determined this with a System.out.println statement on the server which
> >>shows that the string is being passed from the c++ client to the
> >>webservice.
> >>
> >>
> >>
> >>
> >>After that, the app just hangs for about 10 seconds and returns with the
> >>following message:
> >>
> >>
> >>
> >>
> >>execution break
> >>m_MsgSize == 0, so return NULL
> >>Press any key to continue
> >>
> >>
> >>
> >>
> >>Is Axis C++ interoperable with Axis Java?.
> >>Do I need to tweak the WSDL to get this to work?
> >>
> >>
> >>
> >>
> >>If the WSDL2Ws tool isn't generating the proper c++ code, does anyone
> >> know where there is an example of a working c++ client that calls an
> >> echoString type of webservice that I can use as a template?
> >>
> >>
> >>
> >>
> >>Any help would be greatly appreciated.
> >>
> >>
> >>
> >>
> >>Below is a copy of all relevant files:
> >>
> >>
> >>
> >>
> >>====================================================
> >>The Java WS Class:
> >>====================================================
> >>package filemanager.service;
> >>public class EchoCaps{
> >>
> >>
> >>
> >>
> >>    public String capitalize(String in){
> >>        System.out.println("Value passed in from client: " + in);
> >>        return in.toUpperCase();
> >>    }
> >>}
> >>
> >>
> >>
> >>
> >>===========================================================
> >>The WSDL generated from that class, from Axis Java running on Tomcat:
> >>===========================================================
> >>      <wsdl:definitions
> >>targetNamespace="http://localhost:8080/file_manager/services/EchoCaps">
> >>
> >>
> >>
> >>
> >>      <wsdl:message name="capitalizeRequest">
> >><wsdl:part name="inputString" type="xsd:string"/>
> >></wsdl:message>
> >>
> >>
> >>
> >>
> >>      <wsdl:message name="capitalizeResponse">
> >><wsdl:part name="EchoCaps" type="xsd:string"/>
> >></wsdl:message>
> >>
> >>
> >>
> >>
> >>      <wsdl:portType name="EchoCaps">
> >>
> >>
> >>
> >>
> >>      <wsdl:operation name="capitalize" parameterOrder="inputString">
> >><wsdl:input message="impl:capitalizeRequest" name="capitalizeRequest"/>
> >><wsdl:output message="impl:capitalizeResponse"
> >> name="capitalizeResponse"/> </wsdl:operation>
> >></wsdl:portType>
> >>
> >>
> >>
> >>
> >>      <wsdl:binding name="EchoCapsSoapBinding" type="impl:EchoCaps">
> >><wsdlsoap:binding style="rpc"
> >>transport="http://schemas.xmlsoap.org/soap/http"/>
> >>
> >>
> >>
> >>
> >>      <wsdl:operation name="capitalize">
> >><wsdlsoap:operation soapAction=""/>
> >>
> >>
> >>
> >>
> >>      <wsdl:input name="capitalizeRequest">
> >><wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> >>namespace="http://localhost:8080/file_manager/services/EchoCaps"
> >>use="encoded"/>
> >></wsdl:input>
> >>
> >>
> >>
> >>
> >>      <wsdl:output name="capitalizeResponse">
> >><wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> >>namespace="http://localhost:8080/file_manager/services/EchoCaps"
> >>use="encoded"/>
> >></wsdl:output>
> >></wsdl:operation>
> >></wsdl:binding>
> >>
> >>
> >>
> >>
> >>      <wsdl:service name="EchoCapsService">
> >>
> >>
> >>
> >>
> >>      <wsdl:port binding="impl:EchoCapsSoapBinding" name="EchoCaps">
> >><wsdlsoap:address
> >>location="http://localhost:8080/file_manager/services/EchoCaps"/>
> >></wsdl:port>
> >></wsdl:service>
> >></wsdl:definitions>
> >>
> >>
> >>
> >>
> >>==========================================================
> >>The generated cpp file from running WSDL2Ws on the WSDL file above:
> >>==========================================================
> >>/*
> >> * This is the Client Stub implementation file genarated by WSDL2Ws tool.
> >> * EchoCaps.cpp: implemtation for the EchoCaps.
> >> *
> >> */
> >>
> >>
> >>
> >>
> >>#include "EchoCaps.h"
> >>
> >>
> >>
> >>
> >>#include <axis/server/AxisWrapperAPI.h>
> >>
> >>
> >>
> >>
> >>bool CallBase::bInitialized;
> >>CallFunctions CallBase::ms_VFtable;
> >>EchoCaps::EchoCaps()
> >>{
> >>      m_pCall = new Call();
> >>      m_pCall->SetProtocol(APTHTTP);
> >>
> >>
> >>
> >>
> >>m_pCall->SetEndpointURI("http://192.168.0.103:8080/file_manager/services/
> >>E
>
> c
>
> >>hoCaps"); }
> >>
> >>
> >>
> >>
> >>EchoCaps::~EchoCaps()
> >>{
> >>      delete m_pCall;
> >>}
> >>
> >>
> >>
> >>
> >>
> >>/*Methods corresponding to the web service methods*/
> >>
> >>
> >>
> >>
> >>/*
> >> * This method wrap the service methodcapitalize
> >> */
> >>void EchoCaps::capitalize(xsd__string Value0, xsd__string Value1)
> >>{
> >>      if (AXIS_SUCCESS != m_pCall->Initialize(CPP_RPC_PROVIDER,
>
> NORMAL_CHANNEL))
>
> >>return ;
> >>      m_pCall->SetTransportProperty(SOAPACTION_HEADER , "");
> >>      m_pCall->SetSOAPVersion(SOAP_VER_1_1);
> >>      m_pCall->SetOperation("capitalize",
> >>"http://192.168.0.103:8080/file_manager/services/EchoCaps");
> >>      m_pCall->AddParameter((void*)&Value0, "inputString", XSD_STRING);
> >>
> >>
> >>
> >>
> >>
> >>//******************************************************************* //
> >>After commenting out the following line, the client was able to //
> >>successfully send the string to the webservice.
> >>      //m_pCall->AddParameter((void*)&Value1, "EchoCaps", XSD_STRING);
> >>
> >>
> >>
> >>
> >>//*******************************************************************
> >>
> >>
> >>
> >>
> >>      if (AXIS_SUCCESS == m_pCall->Invoke())
> >>      {
> >>              if(AXIS_SUCCESS ==
>
> m_pCall->CheckMessage("capitalizeResponse",
>
> >>"http://192.168.0.103:8080/file_manager/services/EchoCaps"))
> >>              {
> >>                      /*not successful*/
> >>              }
> >>
> >>
> >>
> >>
> >>
> >>      }
> >>      m_pCall->UnInitialize();
> >>}
> >>
> >>
> >>
> >>
> >>//
> >>// Added by me
> >>//
> >>void main(){
> >>      EchoCaps echoCaps;
> >>      echoCaps.capitalize("this is a string", "");
> >>}

-- 
Ben Souther
F.W. Davison & Company, Inc.


This e-mail message, and any accompanying documents, is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information.  Any unauthorized review, use, disclosure, distribution or
copying is prohibited.  If you are not the intended recipient, please
contact our office by email or by telephone at (508) 747-7261 and
immediately destroy all copies of the original message.

Mime
View raw message