You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by ChadDavis <ch...@gmail.com> on 2007/01/09 23:20:22 UTC
[AXIS2] user guide sample / null pointer exception
As per the user guide, I'm trying to run the client and web service
built from Axis2SampleDocLit.wsdl
When I run the client I get a null pointer exception as follows:
Exception in thread "main" java.lang.NullPointerException
at org.apache.axis2.description.ClientUtils.inferInTransport(ClientUtils.java:85)
at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:253)
at org.apache.axis2.userguide.Axis2SampleDocLitServiceStub.echoString(Axis2SampleDocLitServiceStub.java:494)
at chad.test.ClientTester.main(ClientTester.java:20)
I'd appreciate any insight that you might have.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: [AXIS2] user guide sample / null pointer exception
Posted by ChadDavis <ch...@gmail.com>.
Charitha,
Thanks for your help. Well, I used the first try block of the code
you use below. And I used it as you have it, cut and pasted from the
userguide. I only have one of the try blocks though. Did you mean
that I need all three? I thought the three were different ways of
implementing a client. Besides, the first try block throws a null
pointer exception somewhere down inside the stub.echoString() call, so
the other blocks wouldn't get executed anyhow.
What do you think?
On 1/9/07, Charitha Kankanamge <ch...@wso2.com> wrote:
> Hi Chad,
> I just tried out the user guide Axis2SampleDocLit sample and I was able
> to invoke that service by using the client code given in the document.
>
> I used the following client code fragment which is given in the user guide.
>
> package org.apache.axis2.userguide;
>
> public class testclient {
>
> public static void main (String args[]){
>
> try {
> org.apache.axis2.userguide.Axis2SampleDocLitServiceStub stub
> = new
> org.apache.axis2.userguide.Axis2SampleDocLitServiceStub(null,
>
> "http://localhost:8080/axis2/services/Axis2SampleDocLitService");
> //Create the request document to be sent.
> org.apache.axis2.userguide.xsd.EchoStringParamDocument reqDoc =
>
> org.apache.axis2.userguide.xsd.EchoStringParamDocument.Factory.newInstance();
> reqDoc.setEchoStringParam("Axis2 Echo");
> //invokes the Web service.
> org.apache.axis2.userguide.xsd.EchoStringReturnDocument
> resDoc =
> stub.echoString(reqDoc);
> System.out.println(resDoc.getEchoStringReturn());
> } catch (java.rmi.RemoteException e) {
> e.printStackTrace();
> }
>
> try {
> //Create the stub by passing the AXIS_HOME and target EPR.
> //We pass null to the AXIS_HOME and hence the stub will use
> the current directory as the AXIS_HOME
> org.apache.axis2.userguide.Axis2SampleDocLitServiceStub stub =
> new
> org.apache.axis2.userguide.Axis2SampleDocLitServiceStub(null,
>
> "http://localhost:8080/axis2/services/Axis2SampleDocLitService");
> //Create the request document to be sent.
> org.apache.axis2.userguide.xsd.EchoStringArrayParamDocument
> reqDoc =
>
> org.apache.axis2.userguide.xsd.EchoStringArrayParamDocument.Factory.newInstance();
> org.apache.axis2.userguide.xsd.ArrayOfstringLiteral
> paramArray =
>
> org.apache.axis2.userguide.xsd.ArrayOfstringLiteral.Factory.newInstance();
> paramArray.addString("Axis2");
> paramArray.addString("Echo");
> reqDoc.setEchoStringArrayParam(paramArray);
> org.apache.axis2.userguide.xsd.EchoStringArrayReturnDocument
> resDoc =
> stub.echoStringArray(reqDoc);
> //Get the response params
> String[] resParams =
> resDoc.getEchoStringArrayReturn().getStringArray();
> for (int i = 0; i < resParams.length; i++) {
> System.out.println(resParams[i]);
> }
> } catch (java.rmi.RemoteException e) {
> e.printStackTrace();
> }
>
>
> try {
> //Create the stub by passing the AXIS_HOME and target EPR.
> //We pass null to the AXIS_HOME and hence the stub will use the
> current directory as the AXIS_HOME
> org.apache.axis2.userguide.Axis2SampleDocLitServiceStub stub =
> new
> org.apache.axis2.userguide.Axis2SampleDocLitServiceStub(null,
>
> "http://localhost:8080/axis2/services/Axis2SampleDocLitService");
> //Create the request Document
> org.apache.axis2.userguide.xsd.EchoStructParamDocument
> reqDoc =
>
> org.apache.axis2.userguide.xsd.EchoStructParamDocument.Factory.newInstance();
> //Create the complex type
> org.apache.axis2.userguide.xsd.SOAPStruct reqStruct =
>
> org.apache.axis2.userguide.xsd.SOAPStruct.Factory.newInstance();
> reqStruct.setVarFloat(100.50F);
> reqStruct.setVarInt(10);
> reqStruct.setVarString("High");
> reqDoc.setEchoStructParam(reqStruct);
> //Service invocation
> org.apache.axis2.userguide.xsd.EchoStructReturnDocument
> resDoc =
> stub.echoStruct(reqDoc);
> org.apache.axis2.userguide.xsd.SOAPStruct resStruct =
> resDoc.getEchoStructReturn();
> System.out.println("floot Value :" + resStruct.getVarFloat());
> System.out.println("int Value :" + resStruct.getVarInt());
> System.out.println("String Value :" +
> resStruct.getVarString());
> } catch (java.rmi.RemoteException e) {
> e.printStackTrace();
> }
>
> }
>
> }
>
> Can you please make sure your client code is correct?
>
> Regards
> Charitha
>
> ChadDavis wrote:
> > As per the user guide, I'm trying to run the client and web service
> > built from Axis2SampleDocLit.wsdl
> >
> > When I run the client I get a null pointer exception as follows:
> >
> > Exception in thread "main" java.lang.NullPointerException
> > at
> > org.apache.axis2.description.ClientUtils.inferInTransport(ClientUtils.java:85)
> >
> > at
> > org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:253)
> >
> > at
> > org.apache.axis2.userguide.Axis2SampleDocLitServiceStub.echoString(Axis2SampleDocLitServiceStub.java:494)
> >
> > at chad.test.ClientTester.main(ClientTester.java:20)
> >
> > I'd appreciate any insight that you might have.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: [AXIS2] user guide sample / null pointer exception
Posted by Charitha Kankanamge <ch...@wso2.com>.
Hi Chad,
I just tried out the user guide Axis2SampleDocLit sample and I was able
to invoke that service by using the client code given in the document.
I used the following client code fragment which is given in the user guide.
package org.apache.axis2.userguide;
public class testclient {
public static void main (String args[]){
try {
org.apache.axis2.userguide.Axis2SampleDocLitServiceStub stub
= new
org.apache.axis2.userguide.Axis2SampleDocLitServiceStub(null,
"http://localhost:8080/axis2/services/Axis2SampleDocLitService");
//Create the request document to be sent.
org.apache.axis2.userguide.xsd.EchoStringParamDocument reqDoc =
org.apache.axis2.userguide.xsd.EchoStringParamDocument.Factory.newInstance();
reqDoc.setEchoStringParam("Axis2 Echo");
//invokes the Web service.
org.apache.axis2.userguide.xsd.EchoStringReturnDocument
resDoc =
stub.echoString(reqDoc);
System.out.println(resDoc.getEchoStringReturn());
} catch (java.rmi.RemoteException e) {
e.printStackTrace();
}
try {
//Create the stub by passing the AXIS_HOME and target EPR.
//We pass null to the AXIS_HOME and hence the stub will use
the current directory as the AXIS_HOME
org.apache.axis2.userguide.Axis2SampleDocLitServiceStub stub =
new
org.apache.axis2.userguide.Axis2SampleDocLitServiceStub(null,
"http://localhost:8080/axis2/services/Axis2SampleDocLitService");
//Create the request document to be sent.
org.apache.axis2.userguide.xsd.EchoStringArrayParamDocument
reqDoc =
org.apache.axis2.userguide.xsd.EchoStringArrayParamDocument.Factory.newInstance();
org.apache.axis2.userguide.xsd.ArrayOfstringLiteral
paramArray =
org.apache.axis2.userguide.xsd.ArrayOfstringLiteral.Factory.newInstance();
paramArray.addString("Axis2");
paramArray.addString("Echo");
reqDoc.setEchoStringArrayParam(paramArray);
org.apache.axis2.userguide.xsd.EchoStringArrayReturnDocument
resDoc =
stub.echoStringArray(reqDoc);
//Get the response params
String[] resParams =
resDoc.getEchoStringArrayReturn().getStringArray();
for (int i = 0; i < resParams.length; i++) {
System.out.println(resParams[i]);
}
} catch (java.rmi.RemoteException e) {
e.printStackTrace();
}
try {
//Create the stub by passing the AXIS_HOME and target EPR.
//We pass null to the AXIS_HOME and hence the stub will use the
current directory as the AXIS_HOME
org.apache.axis2.userguide.Axis2SampleDocLitServiceStub stub =
new
org.apache.axis2.userguide.Axis2SampleDocLitServiceStub(null,
"http://localhost:8080/axis2/services/Axis2SampleDocLitService");
//Create the request Document
org.apache.axis2.userguide.xsd.EchoStructParamDocument
reqDoc =
org.apache.axis2.userguide.xsd.EchoStructParamDocument.Factory.newInstance();
//Create the complex type
org.apache.axis2.userguide.xsd.SOAPStruct reqStruct =
org.apache.axis2.userguide.xsd.SOAPStruct.Factory.newInstance();
reqStruct.setVarFloat(100.50F);
reqStruct.setVarInt(10);
reqStruct.setVarString("High");
reqDoc.setEchoStructParam(reqStruct);
//Service invocation
org.apache.axis2.userguide.xsd.EchoStructReturnDocument
resDoc =
stub.echoStruct(reqDoc);
org.apache.axis2.userguide.xsd.SOAPStruct resStruct =
resDoc.getEchoStructReturn();
System.out.println("floot Value :" + resStruct.getVarFloat());
System.out.println("int Value :" + resStruct.getVarInt());
System.out.println("String Value :" +
resStruct.getVarString());
} catch (java.rmi.RemoteException e) {
e.printStackTrace();
}
}
}
Can you please make sure your client code is correct?
Regards
Charitha
ChadDavis wrote:
> As per the user guide, I'm trying to run the client and web service
> built from Axis2SampleDocLit.wsdl
>
> When I run the client I get a null pointer exception as follows:
>
> Exception in thread "main" java.lang.NullPointerException
> at
> org.apache.axis2.description.ClientUtils.inferInTransport(ClientUtils.java:85)
>
> at
> org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:253)
>
> at
> org.apache.axis2.userguide.Axis2SampleDocLitServiceStub.echoString(Axis2SampleDocLitServiceStub.java:494)
>
> at chad.test.ClientTester.main(ClientTester.java:20)
>
> I'd appreciate any insight that you might have.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org