• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Use Web Service

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
ManikKS Kashikar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic