File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Axis 2 Client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Axis 2 Client" Watch "Axis 2 Client" New topic
Author

Axis 2 Client

Dhananjay Maan
Greenhorn

Joined: Aug 03, 2007
Posts: 4
HI,
I am creating client using Axis2/eclipse. My Code for calling client is as follows:

InventoryStub inventoryStub = new InventoryStub();

Authentication authentication = new Authentication();

authentication.setUserName("XYZ");
authentication.setPassword("XYZ");
authentication.setClientInitials("XYZ");
authentication.setApplication("XYZ");


GetMarkets getMarkets = new GetMarkets();
getMarkets.setAuthentication(authentication);

InventoryStub.GetMarkets request = new InventoryStub.GetMarkets();

InventoryStub.GetMarketsResponse resp = inventoryStub.getMarkets(request);
System.out.println("Response. .. "+ resp.get_return());

But while I am trying to run this file I am getting following error:


org.apache.axis2.AxisFault: Exception occurred while trying to invoke service method getMarkets
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:435)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:371)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at com.ccds.inventory.ws.InventoryStub.getMarkets(InventoryStub.java:670)
at test.TestGetMarkets.main(TestGetMarkets.java:35)


Can any body tell, why I am getting this error.

Thanks in advance.
Regards,
Dhananjay

Kacee Saxena
Ranch Hand

Joined: Mar 04, 2008
Posts: 54
I dont know whats wrong with yr code. But if your only purpose is to create Client to call the web service , you can use Automatic client generation from WSDL file in Eclipse.
Dhananjay Maan
Greenhorn

Joined: Aug 03, 2007
Posts: 4
Thanks for replying Kacee, I was doing the same as you told but getting this error:

org.apache.axis2.AxisFault: Exception occurred while trying to invoke service method getMarkets
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:435)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:371)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at com.ccds.inventory.ws.InventoryStub.getMarkets(InventoryStub.java:670)
at test.TestGetMarkets.main(TestGetMarkets.java:35


Just want to know the reason of this error.
Regards,
Dhananjay
Manju Sebastian
Greenhorn

Joined: Aug 17, 2009
Posts: 15
Are you sure that getMarket is the proper webservie, also about the parameters and return values. Seems you are calling SOAPmessages, like Request and Response. Just call the stub method, as you arr calling a local method and it should work.

CommandServerService locator = new CommandServerServiceLocator();
CommandServerSoapBindingStub server = (CommandServerSoapBindingStub) locator.getCommandServer(new java.net.URL(SERVICE_URL));

cmd = (LoginCommand)server.executeCommand(null, cmd);


SCJP1.4, SCBCD 5.0, SCDJWS, SCWCD 5.0, SCEA 5.0
Dhananjay Maan
Greenhorn

Joined: Aug 03, 2007
Posts: 4
Thanks Manju,

The method getMarkets is perfectly fine. Actually I am calling third party Web service and the WSDL provided by them is following SOAP 1.2. Thats why I have to use Axis 2 for creating client as Axis 1.x is not supporting SOAP 1.2. Now I have made some modification in WSDL and create client using Axis 1.4. Its working fine at my end, and I am able to get required result.
But the issue is, I am not able to find out what is the error with Axis 2. Can you provide me an example for the same(Creating Java Client using WSDL (SOAP 1.2)).

--
Dhananjay
Manju Sebastian
Greenhorn

Joined: Aug 17, 2009
Posts: 15
Its just the compatibility issues right. If it works, fine.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Axis 2 Client