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 Use Web Service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Use Web Service" Watch "Use Web Service" New topic
Author

Use Web Service

ManikKS Kashikar
Greenhorn

Joined: Mar 27, 2006
Posts: 8
Hi All,

I 'm very new to web services & using axis ,
i have prepared a small web application & want to deploy as a web service
I have copied into /axis as .jws file

made an entry in struts-config.wsdd file &
running my application as
http://localhost:8080/axisT/services/Calculator

can anybody plz help me how to access web service ,i serched somewht i come to know that Java2WSDL command is used for that .

I'm unable to get the exact steps to followed ,
plz help me to run my web application , i want it from scratch

request to all javaranchers for a quick response
also send me a very good link if any body knows for this material

Regards & Thanks
Manik
ManikKS Kashikar
Greenhorn

Joined: Mar 27, 2006
Posts: 8
For the URL like this http://localhost:8080/axisT/services/Calculator?WSDL

I'm getting the o/p as

<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl efinitions targetNamespace="http://localhost:8080/axisT/services/Calculator" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://localhost:8080/axisT/services/Calculator" xmlns:intf="http://localhost:8080/axisT/services/Calculator" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <!--
WSDL created by Apache Axis version: 1.2.1
Built on Jun 14, 2005 (09:15:57 EDT)

-->
- <wsdl:types>
- <schema targetNamespace="http://localhost:8080/axisT/services/Calculator" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
- <complexType name="ArrayOf_soapenc_string">
- <complexContent>
- <restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="soapenc:string[]" />
</restriction>
</complexContent>
</complexType>
</schema>
</wsdl:types>
- <wsdl:message name="addResponse">
<wsdl art name="addReturn" type="xsd:int" />
</wsdl:message>
--- <wsdl ortType name="Calculate">
- <wsdl peration name="main" parameterOrder="args">
<wsdl:input message="impl:mainRequest" name="mainRequest" />
<wsdl utput message="impl:mainResponse" name="mainResponse" />
</wsdl peration>
- <wsdl peration name="add" parameterOrder="a b">
<wsdl:input message="impl:addRequest" name="addRequest" />
<wsdl utput message="impl:addResponse" name="addResponse" />
</wsdl peration>
</wsdl ortType>
- <wsdl:binding name="CalculatorSoapBinding" type="impl:Calculate">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl peration name="main">
<wsdlsoap peration soapAction="" />
- <wsdl:input name="mainRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded" />
</wsdl:input>
- <wsdl utput name="mainResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/axisT/services/Calculator" use="encoded" />
</wsdl utput>
</wsdl peration>
- <wsdl peration name="add">
<wsdlsoap peration soapAction="" />
- <wsdl:input name="addRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded" />
</wsdl:input>
- <wsdl utput name="addResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/axisT/services/Calculator" use="encoded" />
</wsdl utput>
</wsdl peration>
</wsdl:binding>
- <wsdl:service name="CalculateService">
- <wsdl ort binding="impl:CalculatorSoapBinding" name="Calculator">
<wsdlsoap:address location="http://localhost:8080/axisT/services/Calculator" />
</wsdl ort>
</wsdl:service>
</wsdl efinitions>


so wht is this code ,is this wsdl?
only snapshot given

plz reply me soon
Thanks & Regards
Manik
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39549
    
  27
What you posted is WSDL. You can use that to create client-side classes that access the web service using the WSDL2Java tool that comes with Axis.

An easier way -since you already have the Calculator class as a JWS file in the axis directory- is to use the CalcClient class, which comes with Axis in the samples/userguide/Example2 directory. It demonstrates how to access the Calculator service.

I'm not sure why you're modifying a Struts config file - it has nothing to do with Axis.


Ping & DNS - updated with new look and Ping home screen widget
ManikKS Kashikar
Greenhorn

Joined: Mar 27, 2006
Posts: 8
hi Ulf Dittmer ,

So now i have wsdl file & Calcclient.java to access my web service , plz tell me wht steps should i do now
i'm trying from last 3 dys
plz help me

requesting for a early response

ok
Bye
Manik
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39549
    
  27
You compile the CalcClient and run it. You do not need to use the WSDL, because CalcClient already knows everything about the Calculator service that it needs to access it.
ManikKS Kashikar
Greenhorn

Joined: Mar 27, 2006
Posts: 8
Hi,
Sorry i'm troubling u ,but my code is not running
plz give me the steps ,also
i heard something about WSDL2Java
Here is my code client side

import javax.xml.rpc.*;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;
import javax.xml.rpc.handler.*;
import javax.xml.rpc.ParameterMode;
import org.apache.axis.wsdl.*;



public class CalcClient {



public static void main(String [] args) throws Exception {
Options options = new Options(args);

String endpoint = "http://localhost:" + options.getPort() +
"/axisT/Calculate.jws";

args = options.getRemainingArgs();

if (args == null || args.length != 3) {
System.err.println("Usage: CalcClient <add|subtract arg1 arg2");
return;
}

String method = args[0];
if (!(method.equals("add") || method.equals("subtract"))) {
System.err.println("Usage: CalcClient <add|subtract arg1 arg2");
return;
}

// Make the call
Integer i1 = new Integer(args[1]);
Integer i2 = new Integer(args[2]);

Service service = new Service();
Call call = (Call) service.createCall();

call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName( method );
call.addParameter("op1", XMLType.XSD_INT, ParameterMode.IN);
call.addParameter("op2", XMLType.XSD_INT, ParameterMode.IN);
call.setReturnType(XMLType.XSD_INT);

Integer ret = (Integer) call.invoke( new Object [] { i1, i2 });

System.out.println("Got result : " + ret);
}
}
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39549
    
  27
but my code is not running

What does this mean? Are you getting exceptions? If so, which ones, and in what line of code are they occurring?
Manesh Kumar
Ranch Hand

Joined: Mar 21, 2006
Posts: 94

String endpoint = "http://localhost:" + options.getPort() +
"/axisT/Calculate.jws";


Is it Calculate or Calculator?

Please verify.
[ April 04, 2006: Message edited by: Dilip Kumar Jain ]

Manesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Use Web Service
 
Similar Threads
Axis and JBOSS
Axis and JBOSS
calling wsdl in a jsp
Using Axis ,but unable to get WSDL for parameterised method
Can't see the WSDL file