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 Webservice client code generation using axis2 and eclipse galilio Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Webservice client code generation using axis2 and eclipse galilio" Watch "Webservice client code generation using axis2 and eclipse galilio" New topic
Author

Webservice client code generation using axis2 and eclipse galilio

DhaKatta Dha
Greenhorn

Joined: Aug 25, 2009
Posts: 12
Hi,

I'm new to webservice client code calling from external service in different machine with given ipaddress. I would need to generate a client call and call one service and add logic to it using axis2 ,eclipse galilio.

Please provide me steps and how to deploy it if the service is not in our local axis2 server.

Regards
-TanKatta
Alex Bokov
Greenhorn

Joined: Jun 01, 2009
Posts: 16
May be it will help:
http://www.eclipse.org/webtools/community/tutorials/BottomUpAxis2WebService/bu_tutorial.html
Second part described how to create java ws client.
DhaKatta Dha
Greenhorn

Joined: Aug 25, 2009
Posts: 12
Hey Alex,

Thank you very much for your reply. I have read this article before and I have questions in it.

1. My service which I call is not in my local axis server. It a remote service running in external server.
2. I have to get connected to that remote server through its IP and then make a call to that service.

3. The question related to this tutorial is it generated 2 classes called stub and callbackhandler. Both java classes. How do I code the call to make to the service.

Do I edit the stub class or just make an instance of stub and call the service and its method in a different java class just for calling the service? Some examples online gave service client calls instance some examples gave servicelocator class instance. When do we use which in my eclipse with the generated classes (stub and callbackhandler) how do i make a call to the service?

Can you please give me the steps

Alex Bokov
Greenhorn

Joined: Jun 01, 2009
Posts: 16
There are different services implementations as I understand (I’m novice in ws to0 ) , at least Axis, and Axis2.
I have worked only with Axis2 and probably will be able to explain how to create client for it.
If you will give me that wsdl url (something like http://somecompany.com/services/SomeService?wsdl) I could try to
create client if there is no special credentials (password, user_name).
DhaKatta Dha
Greenhorn

Joined: Aug 25, 2009
Posts: 12
Hi Alex,

Thank you very much for your reply. I have the wsdl but its not a url as its given as .wsdl to me. Yes we definitly need credentials for username and password.

We need to connect to that external server through username and password then call the service and its method.

I installed axis2 as plugin to eclipse galilio with axis2 code gen and axis2 service archiver.

So far what I did is I created a dynamic project and tomcat 6.0.20 server added to it and pasted the wsdl under webcontent by creating wsdl folder. Then by right clicking the wsdl file->new->Web service client and it generated 2 java classes. stub and callbackhandler(I choose both for sync and async for client).

Now my question is how do I make a call to the service with a url is it by using the stub instance?Shall I create new java class and call a method in
my wsdl I have a request method with parameters for username/password,url.
Is that the way we have to work with axis and eclipse galilio with the autogenerated stub and callbackhandler?

I'm not able to send my wsdl?

Here are the dependent xsds for the wsdl.

Transfermanagement.xsd there are 2 more dependent xsd not giving here and you may not be able to generate the client as this message is getting too bigger.
if you have the mailid I can send to you.

Regards
Katta

Alex Bokov
Greenhorn

Joined: Jun 01, 2009
Posts: 16
wsdl is xml file which contains all descriptions about web service.
Base on that wsdl eclipse generated classes what you will need to work with this particular web service
(in your case stub and callbackhandler).
Now you can use them from any other class.

this is example of how I used it:



may be it will help
DhaKatta Dha
Greenhorn

Joined: Aug 25, 2009
Posts: 12
Hi Alex,

Thank you very much for your reply. Its very helpful to me. I'm working on the code. I will post the resply soon after testing it. Because it being the external server may take some time to get connection as wen have to notify the server to be up ahead of time.

Still the question aI have is for this to be build and deploy do I need just axis and tomcat any ant/maven?

Can you please explain me the deployment steps.

If it is handed over to thirdparty what dependencies can I tell them to use?

But this reply from you is very much understandable.

Regards
-Katta
DhaKatta Dha
Greenhorn

Joined: Aug 25, 2009
Posts: 12
Hi Alex,

After your response this is my second message.

I have done something like this based on what I understood. My question is how do I call the wsdl by connecting to the server. I thin k QName is used for calling a service in the WSDL am I right?

import java.rmi.RemoteException;

import javax.xml.namespace.QName;


import org.apache.axis2.AxisFault;
import org.apache.axis2.client.ServiceClient;
import com.dolby.www.dcinema.ws.smi.v1.TransferManagement_v1_0Stub.TransferContentRequest;
import com.dolby.www.dcinema.ws.smi.v1.TransferManagement_v1_0Stub.TransferContentResponse;

public class testTransfer {
public static void main(String args[]) throws RemoteException, Fault{

TransferManagement_v1_0Stub TMS=new TransferManagement_v1_0Stub();
ServiceClient sc=TMS._getServiceClient();

sc=TMS._getServiceClient();
sc.addStringHeader(new QName("",""),"" );
com.dolby.www.dcinema.ws.smi.v1.TransferManagement_v1_0Stub tmStub=new com.dolby.www.dcinema.ws.smi.v1.TransferManagement_v1_0Stub();
TransferContentRequest trReq=new TransferContentRequest();
trReq.setUserName("");
trReq.setPassword("");
//trReq.setUrl();
TransferContentResponse tcresponse=tmStub.transferContent(trReq);
System.out.println(tcresponse.getTransferId());


}
DhaKatta Dha
Greenhorn

Joined: Aug 25, 2009
Posts: 12
Hi Alex,

I'm posting some part of my wsdl for understanding to make a call to the url and call any serice from the wsdl and its methos and about QName used in the client code.

<wsdl:definitions name="TransferManagement_v1"
targetNamespace="http://www.dolby.com/dcinema/ws/smi/v1"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.dolby.com/dcinema/ws/smi/v1"
xmlns:tra="http://www.dolby.com/dcinema/ws/smi/v1/schemas/transfermanagement"
xmlns:com="http://www.dolby.com/dcinema/ws/smi/v1/schemas/common"
xmlns:flt="http://www.dolby.com/dcinema/ws/smi/v1/schemas/fault"
xmlns:v1_0="http://www.dolby.com/dcinema/ws/smi/v1_0"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<!-- Request/Response Schema Definitions -->

<wsdl:types>
<xsd:schema targetNamespace="http://www.dolby.com/dcinema/ws/smi/v1_0">

<xsd:import schemaLocation="TransferManagement.xsd" namespace="http://www.dolby.com/dcinema/ws/smi/v1/schemas/transfermanagement"/>
<xsd:import schemaLocation="Common.xsd" namespace="http://www.dolby.com/dcinema/ws/smi/v1/schemas/common"/>
<xsd:import schemaLocation="Fault.xsd" namespace="http://www.dolby.com/dcinema/ws/smi/v1/schemas/fault"/>

<!-- transferContent elements -->

<xsd:element name="transferContentRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="transferType" type="tra:NetworkTransferType" minOccurs="0"/>
<xsd:element name="transferProtocolType" type="tra:TransferProtocolType" minOccurs="0"/>
<xsd:element name="contentType" type="com:ContentType" minOccurs="0"/>
<xsd:element name="auditoriumNumber" type="xsd:string" minOccurs="0"/>
<xsd:element name="destinationContentStore" type="com:ContentStoreType" minOccurs="0"/>
<xsd:element name="url" type="xsd:anyURI"/>
<xsd:element name="userName" type="xsd:string" minOccurs="0"/>
<xsd:element name="password" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>




Other part in the bottm is:

<wsdl:binding name="TransferManagementBinding_v1_0" type="tns:TransferManagementService_v1_0">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

<wsdlperation name="transferContent">
<soapperation soapAction="http://www.dolby.com/dcinema/ws/smi/v1/transferContent"/>
<wsdl:input name="transferContentRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdlutput name="transferContentResponse">
<soap:body use="literal"/>
</wsdlutput>
<wsdl:fault name="transferContentFault">
<soap:fault name="transferContentFault" use="literal"/>
</wsdl:fault>
</wsdlperation>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Webservice client code generation using axis2 and eclipse galilio