axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Perry2 <PERR...@uk.ibm.com>
Subject Re: Re-use of generated Stub/Proxy object
Date Tue, 22 Jun 2004 11:19:53 GMT




Susantha,

I understand that the code should work fine, but there is still a problem.
Also I am now using version 1.2.

I have a client class that instantiates the stub in its constructor and
uses the stub in each of its methods. If a method uses the stub twice, then
the second call via the stub will fail.

I have a simple web service which just tests the primitive types, int,
long, etc. In the code snippets below you can see how I am constructing the
class and using the stub as in Example 1. In Example 2 where I make a set
call to the web service, then a get call to the service, the get (2nd) call
fails. I can see from the output of the service that the set called
succeeded and the get called succeeded, but when the get (2nd) call is
returned to the client stub something goes wrong and the stub returns an
unitialised value. In Example 3 I instantiate a new temporary local
instance of the stub and by using this everything works.

The code snippets are not the real code and are only a representation of
what is being done. This has been done for clarity.

-----------------------------------------
code snippets

// Constructor
ClientTest::ClientTest(const char *new_endpoint) {
      // TestService *ts;  // defined in .h file
      // char *endpoint; // defined in .h file
      endpoint = strdup(new_endpoint); // So endpoint can be used later.
      ts = new TestService(endpoint);
}

// Example 1
// This work OK
int ClientTest::getInt() {
      return ts.getInt();
}

// Example 2
// The web service stores the value of the setInt and returns it on the
next getInt call
// This does not work. No exception is thrown, but an uninitialised value
is returned from ts.getInt()
int ClientTest::setInt() {
      ts.setInt(25);
      return ts.getInt();
}

// Example 3
// This works.
int ClientTest::setInt() {
      ts.setInt(25);
      TestService *ok = new TestService(endpoint);
      return ok.getInt();
}

------------------------------

I have tried with a sleep between the calls so know that it is not a timing
issue. Stepping through with the debugger I can see that it is the
SoapDeSerializer::getBody() call which is failing. The m_pNode variable is
pointing to the SOAP envelope node and not the SOAP body node.

I hope this helps to clarify where the problem lies.

Regards,

Andrew Perry
Web Services Client Technologies Test
perryan@uk.ibm.com
Mail Point 102
IBM UK Laboratories. Hursley Park, Winchester, Hants. SO21 2JN
Tel. Internal 24-9828  External + 44 (0)1962 819828
Fax. + 44(0)1962 818080


                                                                           
             Susantha Kumara                                               
             <susantha@opensou                                             
             rce.lk>                                                    To 
                                       Apache AXIS C User List             
             22/06/2004 05:13          <axis-c-user@ws.apache.org>         
                                                                        cc 
                                                                           
             Please respond to                                     Subject 
              "Apache AXIS C           Re: Re-use of generated Stub/Proxy  
                User List"             object                              
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Your code should work fine with Axis 1.1.x. See the interop samples and
simple Calculator sample. They work in the same way using a single stub
instance.

Susantha.
---

On Wed, 2004-06-16 at 20:37, Andrew Perry2 wrote:
>
> I have a Java Web Service callled TestService running in WebSphere and
used
> WSDL2Ws.jar to generate the Stubs/Proxy code for the client to call the
> service. In version 1.0 of AXIS C++ I was able to use a single instance
of
> the generated TestService class to make all the calls in my test client
> instantiated in the constructor of the ClientTest class (see code snippet
> below), and the instance was just re-used. This worked without problems
for
> the 28 different tests that I have currently have.
>
> Since upgrading to 1.1.x this no longer works. For each method called in
> the TestService class a new instance of the TestService needs to
> instantiated. I haven't tried 1.2 yet. I'm using the xerces.2.2.0 parser.
>
> Was this change in behaviour planned? What are the official
rules/guidance
> for Stub/Proxy re-use?
>
>
> ------------------------------------------------------------------
> (Code snippet: brevity used for clarity)
>
> ClientTest::ClientTest(const char *endpoint) {
>       ws = new TestService(endpoint);
> }
>
> bool ClientTest::getInt() {
>       int expected = 10;
>       int intReturn = ws->getDataInt();
>       return (expected == intReturn);
> }
>
> bool ClientTest::getLong() {
>       long expected = 10;
>       long longReturn = ws->getDataLong();
>       return (expected == longReturn);
> }
>
> ------------------------------------------------------------------
>
> Regards,
>
> Andrew Perry
>
>




Mime
View raw message