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 Plorks mail <pl...@hotmail.com> on 2005/08/31 18:07:19 UTC
creating WSDL contract
Hi all
can anyone give me an example of writing a WSDL contract so i can later do
wsdl2java?
i'm after an example that retruns xml/arrays/strings
what editors are best to create the wsdl file?
thanks for any help
_________________________________________________________________
Be the first to hear what's new at MSN - sign up to our free newsletters!
http://www.msn.co.uk/newsletters
Re: creating WSDL contract
Posted by Plorks mail <pl...@hotmail.com>.
Thanks Mike
Very kind of you
>From: Mike Woinoski <ne...@pineneedleconsulting.com>
>Reply-To: axis-user@ws.apache.org
>To: axis-user@ws.apache.org
>Subject: Re: creating WSDL contract
>Date: Sun, 04 Sep 2005 11:06:27 -0400
>
>Plorks mail wrote:
>>can anyone give me an example of writing a WSDL contract so i can later do
>>wsdl2java?
> >
> > i'm after an example that retruns xml/arrays/strings
>
>Example WSDL and imported schema below. Note the updatePatientRecord
>element has a child named visitDetails that is declared with
>maxOccurs="unbounded". This is the WS-I recommendation for handling arrays.
>
>To generate template Java files and deploy.wsdd:
>
> java org.apache.axis.wsdl.WSDL2Java --server-side --package mypackage
> --output . OfficeVisitService.wsdl
>
>Generate server-config.wsdd using AdminClient or using the Admin utility:
> java org.apache.axis.utils.Admin -server deploy.wsdd
>
>>what editors are best to create the wsdl file?
>
>The WTP Eclipse plug-in includes a very nice WSDL editor:
>www.eclipse.org/webtools
>
>Cape Science offers a free stand-alone WSDL editor: www.capescience.com/soa
>
>Mike
>
>================ Service WSDL ========================================
>
><?xml version="1.0" encoding="UTF-8"?>
><wsdl:definitions
> targetNamespace="http://www.ltree.com/wsdl/officevisit"
> xmlns:impl="http://www.ltree.com/wsdl/officevisit"
> xmlns:tns="http://www.ltree.com/types"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
> >
>
> <wsdl:types>
> <xsd:schema
> targetNamespace="http://www.ltree.com/types"
> xmlns:tns="http://www.ltree.com/types"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
>
> <!-- schema shown after WSDL -->
> <xsd:include
> schemaLocation="http://localhost:8080/schemas/PatientRecord.xsd"
>/>
>
> <xsd:element name="updatePatientRecord">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="patientInfo"
>type="tns:PatientInfo"/>
> <xsd:element name="visitDetails"
>type="tns:VisitDetails"
> minOccurs="0" maxOccurs="unbounded"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
>
> <xsd:element name="updatePatientRecordResponse">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="patientRecord"
>type="tns:PatientRecord"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
>
> </xsd:schema>
> </wsdl:types>
>
> <wsdl:message name="updatePatientRecordRequest">
> <wsdl:part name="parameters" element="tns:updatePatientRecord"/>
> </wsdl:message>
>
> <wsdl:message name="updatePatientRecordResponse">
> <wsdl:part name="parameters"
>element="tns:updatePatientRecordResponse"/>
> </wsdl:message>
>
> <wsdl:portType name="OfficeVisit">
> <wsdl:operation name="updatePatientRecord">
> <wsdl:input message="impl:updatePatientRecordRequest"
> name="updatePatientRecordRequest"/>
> <wsdl:output message="impl:updatePatientRecordResponse"
> name="updatePatientRecordResponse"/>
> </wsdl:operation>
> </wsdl:portType>
>
> <wsdl:binding name="OfficeVisitBinding" type="impl:OfficeVisit">
>
> <wsdlsoap:binding
> style="document"
> transport="http://schemas.xmlsoap.org/soap/http"/>
>
> <wsdl:operation name="updatePatientRecord">
> <wsdlsoap:operation soapAction=""/>
>
> <wsdl:input name="updatePatientRecordRequest">
> <wsdlsoap:body use="literal" />
> </wsdl:input>
>
> <wsdl:output name="updatePatientRecordResponse">
> <wsdlsoap:body use="literal"/>
> </wsdl:output>
>
> </wsdl:operation>
> </wsdl:binding>
>
> <wsdl:service name="OfficeVisitServicePorts">
> <wsdl:port binding="impl:OfficeVisitBinding"
>name="OfficeVisitService">
> <wsdlsoap:address
>location="http://localhost:8080/ex51solBonus/services/OfficeVisitService"/>
> </wsdl:port>
> </wsdl:service>
>
></wsdl:definitions>
>
>
>
>================ PatientRecord.xsd Schema
>======================================
>
><?xml version="1.0" encoding="iso-8859-1"?>
><xsd:schema
> targetNamespace="http://www.ltree.com/types"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:tns="http://www.ltree.com/types"
> elementFormDefault="qualified">
>
> <xsd:complexType name="PatientRecord">
> <xsd:sequence>
> <xsd:element name="patientInfo" type="tns:PatientInfo"/>
> <xsd:element name="visitDetails" type="tns:VisitDetails"
> minOccurs="0" maxOccurs="unbounded"/>
> </xsd:sequence>
> <xsd:attribute name="id" type="xsd:string" use="required"/>
> </xsd:complexType>
>
> <xsd:complexType name="PatientInfo">
> <xsd:sequence>
> <xsd:element name="name" type="xsd:string"/>
> <xsd:element name="address" type="xsd:string"/>
> </xsd:sequence>
> </xsd:complexType>
>
> <xsd:complexType name="VisitDetails">
> <xsd:sequence>
> <xsd:element name="date" type="xsd:string"/>
> <xsd:element name="workCompleted" type="xsd:string"/>
> <xsd:element name="fee" type="xsd:decimal"/>
> </xsd:sequence>
> </xsd:complexType>
>
></xsd:schema>
>
>
_________________________________________________________________
Winks & nudges are here - download MSN Messenger 7.0 today!
http://messenger.msn.co.uk
Re: creating WSDL contract
Posted by Mike Woinoski <ne...@pineneedleconsulting.com>.
Plorks mail wrote:
> can anyone give me an example of writing a WSDL contract so i can later
> do wsdl2java?
>
> i'm after an example that retruns xml/arrays/strings
Example WSDL and imported schema below. Note the updatePatientRecord element has
a child named visitDetails that is declared with maxOccurs="unbounded". This is
the WS-I recommendation for handling arrays.
To generate template Java files and deploy.wsdd:
java org.apache.axis.wsdl.WSDL2Java --server-side --package mypackage
--output . OfficeVisitService.wsdl
Generate server-config.wsdd using AdminClient or using the Admin utility:
java org.apache.axis.utils.Admin -server deploy.wsdd
> what editors are best to create the wsdl file?
The WTP Eclipse plug-in includes a very nice WSDL editor: www.eclipse.org/webtools
Cape Science offers a free stand-alone WSDL editor: www.capescience.com/soa
Mike
================ Service WSDL ========================================
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
targetNamespace="http://www.ltree.com/wsdl/officevisit"
xmlns:impl="http://www.ltree.com/wsdl/officevisit"
xmlns:tns="http://www.ltree.com/types"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
>
<wsdl:types>
<xsd:schema
targetNamespace="http://www.ltree.com/types"
xmlns:tns="http://www.ltree.com/types"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<!-- schema shown after WSDL -->
<xsd:include
schemaLocation="http://localhost:8080/schemas/PatientRecord.xsd" />
<xsd:element name="updatePatientRecord">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="patientInfo" type="tns:PatientInfo"/>
<xsd:element name="visitDetails" type="tns:VisitDetails"
minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="updatePatientRecordResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="patientRecord" type="tns:PatientRecord"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="updatePatientRecordRequest">
<wsdl:part name="parameters" element="tns:updatePatientRecord"/>
</wsdl:message>
<wsdl:message name="updatePatientRecordResponse">
<wsdl:part name="parameters" element="tns:updatePatientRecordResponse"/>
</wsdl:message>
<wsdl:portType name="OfficeVisit">
<wsdl:operation name="updatePatientRecord">
<wsdl:input message="impl:updatePatientRecordRequest"
name="updatePatientRecordRequest"/>
<wsdl:output message="impl:updatePatientRecordResponse"
name="updatePatientRecordResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="OfficeVisitBinding" type="impl:OfficeVisit">
<wsdlsoap:binding
style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="updatePatientRecord">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="updatePatientRecordRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
<wsdl:output name="updatePatientRecordResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="OfficeVisitServicePorts">
<wsdl:port binding="impl:OfficeVisitBinding" name="OfficeVisitService">
<wsdlsoap:address
location="http://localhost:8080/ex51solBonus/services/OfficeVisitService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
================ PatientRecord.xsd Schema ======================================
<?xml version="1.0" encoding="iso-8859-1"?>
<xsd:schema
targetNamespace="http://www.ltree.com/types"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.ltree.com/types"
elementFormDefault="qualified">
<xsd:complexType name="PatientRecord">
<xsd:sequence>
<xsd:element name="patientInfo" type="tns:PatientInfo"/>
<xsd:element name="visitDetails" type="tns:VisitDetails"
minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string" use="required"/>
</xsd:complexType>
<xsd:complexType name="PatientInfo">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="address" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="VisitDetails">
<xsd:sequence>
<xsd:element name="date" type="xsd:string"/>
<xsd:element name="workCompleted" type="xsd:string"/>
<xsd:element name="fee" type="xsd:decimal"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Re: creating WSDL contract
Posted by Anne Thomas Manes <at...@gmail.com>.
You might also try Cape Clear's SOA Editor.
See http://www.capescience.com/soa/index.shtml.
Anne
On 8/31/05, Guy Rixon <gt...@ast.cam.ac.uk> wrote:
>
> On Wed, 31 Aug 2005, Plorks mail wrote:
>
> > what editors are best to create the wsdl file?
>
> I use oXygen (http://www.oxygenxml.com/) which now has WSDL
> schema-checking
> built in.
>
> Guy Rixon gtr@ast.cam.ac.uk
> Institute of Astronomy Tel: +44-1223-337542
> Madingley Road, Cambridge, UK, CB3 0HA Fax: +44-1223-337523
>
Re: creating WSDL contract
Posted by Guy Rixon <gt...@ast.cam.ac.uk>.
On Wed, 31 Aug 2005, Plorks mail wrote:
> what editors are best to create the wsdl file?
I use oXygen (http://www.oxygenxml.com/) which now has WSDL schema-checking
built in.
Guy Rixon gtr@ast.cam.ac.uk
Institute of Astronomy Tel: +44-1223-337542
Madingley Road, Cambridge, UK, CB3 0HA Fax: +44-1223-337523
Re: java.lang.reflect.InvocationTargetException
Posted by Guy Rixon <gt...@ast.cam.ac.uk>.
On Thu, 1 Sep 2005, A Yang wrote:
> Deserialization of the message payload?
Yes, either in the service or in the client when the response comes back.
> How important are the contents of the SOAP Envelope and Header? i.e.,
> does the first child element in the body have to have the same name as
> the method I wish to invoke? And do I have to keep the namespace in
> synch with my implementation somehow?
Namespace sync'd to implementation yes, via the WSDD. The first child in the
body _may_ need to be named after the operation in order to satisfy the WSDL
contract. However, the service doesn't generally read the WSDL, so that's
probably not your problem here.
> I've just been making sure that my service name, class name and method
> name are in synch between the implementation and the deployment
> descriptor. The actual XML being sent by my client via the
> SOAPConnection.call() method basically has nothing in it.
Sounds reasonable.
> So do I have to ensure that the service or method name is specified
> somewhere in the SOAP payload in order to trigger the service? I
> thought with Messaging style services, Axis just passed everything
> along.
>
> Thanks,
> Andy
>
> --- Guy Rixon <gt...@ast.cam.ac.uk> wrote:
>
> > On Wed, 31 Aug 2005, A Yang wrote:
> >
> > > What does the InvocationTargetException usually indicate?
> >
> > It usually means a failure in deserialization.
> >
> > Guy Rixon gtr@ast.cam.ac.uk
> > Institute of Astronomy Tel: +44-1223-337542
> > Madingley Road, Cambridge, UK, CB3 0HA Fax: +44-1223-337523
> >
>
>
>
>
>
>
>
> __________________________________________________________
> Find your next car at http://autos.yahoo.ca
>
Guy Rixon gtr@ast.cam.ac.uk
Institute of Astronomy Tel: +44-1223-337542
Madingley Road, Cambridge, UK, CB3 0HA Fax: +44-1223-337523
Re: java.lang.reflect.InvocationTargetException
Posted by A Yang <ay...@yahoo.ca>.
Deserialization of the message payload?
How important are the contents of the SOAP Envelope and Header? i.e.,
does the first child element in the body have to have the same name as
the method I wish to invoke? And do I have to keep the namespace in
synch with my implementation somehow?
I've just been making sure that my service name, class name and method
name are in synch between the implementation and the deployment
descriptor. The actual XML being sent by my client via the
SOAPConnection.call() method basically has nothing in it.
So do I have to ensure that the service or method name is specified
somewhere in the SOAP payload in order to trigger the service? I
thought with Messaging style services, Axis just passed everything
along.
Thanks,
Andy
--- Guy Rixon <gt...@ast.cam.ac.uk> wrote:
> On Wed, 31 Aug 2005, A Yang wrote:
>
> > What does the InvocationTargetException usually indicate?
>
> It usually means a failure in deserialization.
>
> Guy Rixon gtr@ast.cam.ac.uk
> Institute of Astronomy Tel: +44-1223-337542
> Madingley Road, Cambridge, UK, CB3 0HA Fax: +44-1223-337523
>
__________________________________________________________
Find your next car at http://autos.yahoo.ca
Re: java.lang.reflect.InvocationTargetException
Posted by Guy Rixon <gt...@ast.cam.ac.uk>.
On Wed, 31 Aug 2005, A Yang wrote:
> What does the InvocationTargetException usually indicate?
It usually means a failure in deserialization.
Guy Rixon gtr@ast.cam.ac.uk
Institute of Astronomy Tel: +44-1223-337542
Madingley Road, Cambridge, UK, CB3 0HA Fax: +44-1223-337523
Re: java.lang.reflect.InvocationTargetException
Posted by Mike Woinoski <ne...@pineneedleconsulting.com>.
Andy,
Do you really want a message style service? Or is your true goal to have a
document/literal service where you have control over the wsdl and schema? Axis
message-style services are a real pain because (a) you have to use SAAJ, and (b)
they're not portable to other Java web service toolkits. If what you really want
is just a doc/lit service, I've found that it's much easier to start with the
wsdl and schema that you want, and then generate service source files using
"WSDL2Java --server-side". Here's what I do:
1. copy an existing doc/lit service WSDL file
2. edit the WSDL to define a new portType, new operations, etc. Import schemas
using the <xsd:include> or <xsd:import> elements. The WTP plugin for Eclipse has
a nice WSDL editor.
3. validate your WSDL using the Analyzer from the WS-I Interoperability Testing
Tools (http://ws-i.org/deliverables/workinggroup.aspx?wg=testingtools)
4. run "WSDL2Java --server-side" to generate template source files and JAX-RPC
value types (JavaBeans) that allow you to work with the SOAP elements without
having to resort to SAAJ. (The generated deploy.wsdd will define the service's
style="wrapped", which is just another flavor of "document".)
5. edit the generated service implementation class
[service-name]SoapBinding.java and add business logic as needed
6. deploy the service as usual
Since the new releases of Axis have much better support for doc/lit services
than the old releases, you may never need to use Axis message style services.
Mike
A Yang wrote:
> Hi there,
>
> I'm trying to create a very simple Message style service in Axis 1.2.1
> running in Tomcat 5.5.9 and JDK 1.5.0_04-b05 on Windows XP.
>
> I have a simple class:
>
> package com.xyz.testbed;
>
> import javax.xml.soap.*;
>
> public class CheckValue
> {
> public void foo(SOAPEnvelope req, SOAPEnvelope resp)
> {
> try
> {
> SOAPBody respbody = resp.getBody();
> }
> catch(Exception e) {}
> }
> }
>
> with a deploy.wsdd that looks like:
>
> <deployment name="test" xmlns="http://xml.apache.org/axis/wsdd/"
> xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
> xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
> <service name="Monkey" style="message">
> <parameter name="className" value="com.xyz.testbed.CheckValue"/>
> <parameter name="allowedMethods" value="foo"/>
> </service>
> </deployment>
>
> I deploy it using the AdminClient and it reports everything is fine.
> The server-config.wsdd has the following:
>
> <service name="Monkey" provider="java:MSG" style="message"
> use="literal">
> <parameter name="allowedMethods" value="foo"/>
> <parameter name="className"
> value="com.hipaat.testbed.commands.CheckConsent"/>
> </service>
>
> However, when I try to invoke the service from a test client using:
>
> SOAPConnection conn =
> SOAPConnectionFactory.newInstance().createConnection();
> SOAPMessage response = conn.call(smsg,
> "http://localhost:8080/axis/services/Monkey");
> // smsg is a SOAPMessage created from a string - this was taken from
> samples.message.TestMsg
>
> I get the following response:
>
> <?xml version="1.0" encoding="utf-8"?>
> <soapenv:Envelope
> mlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <soapenv:Body>
> <soapenv:Fault>
> <faultcode>soapenv:Server.userException</faultcode>
> <faultstring>java.lang.reflect.InvocationTargetException</faultstring>
> <detail><ns1:hostname
> xmlns:ns1="http://xml.apache.org/axis/">workstation</ns1:hostname>
> </detail>
> </soapenv:Fault>
> </soapenv:Body>
> </soapenv:Envelope>
>
> I can invoke the sample.message.TestMsg no problem (I don't get a
> response, but I think that's correct? Haven't run this using TCPMonitor
> yet)
>
> What does the InvocationTargetException usually indicate? I've tried
> implementing my service as both:
>
> public void foo(SOAPEnvelope req, SOAPEnvelope resp)
>
> and
>
> public void foo(SOAPEnvelope req, SOAPEnvelope resp) throws
> javax.xml.soap.SOAPException
>
> but both produce the same result.
>
> Any thoughts?
>
> Thanks in advance,
> Andy
>
>
>
>
>
>
> __________________________________________________________
> Find your next car at http://autos.yahoo.ca
>
java.lang.reflect.InvocationTargetException
Posted by A Yang <ay...@yahoo.ca>.
Hi there,
I'm trying to create a very simple Message style service in Axis 1.2.1
running in Tomcat 5.5.9 and JDK 1.5.0_04-b05 on Windows XP.
I have a simple class:
package com.xyz.testbed;
import javax.xml.soap.*;
public class CheckValue
{
public void foo(SOAPEnvelope req, SOAPEnvelope resp)
{
try
{
SOAPBody respbody = resp.getBody();
}
catch(Exception e) {}
}
}
with a deploy.wsdd that looks like:
<deployment name="test" xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
<service name="Monkey" style="message">
<parameter name="className" value="com.xyz.testbed.CheckValue"/>
<parameter name="allowedMethods" value="foo"/>
</service>
</deployment>
I deploy it using the AdminClient and it reports everything is fine.
The server-config.wsdd has the following:
<service name="Monkey" provider="java:MSG" style="message"
use="literal">
<parameter name="allowedMethods" value="foo"/>
<parameter name="className"
value="com.hipaat.testbed.commands.CheckConsent"/>
</service>
However, when I try to invoke the service from a test client using:
SOAPConnection conn =
SOAPConnectionFactory.newInstance().createConnection();
SOAPMessage response = conn.call(smsg,
"http://localhost:8080/axis/services/Monkey");
// smsg is a SOAPMessage created from a string - this was taken from
samples.message.TestMsg
I get the following response:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
mlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>java.lang.reflect.InvocationTargetException</faultstring>
<detail><ns1:hostname
xmlns:ns1="http://xml.apache.org/axis/">workstation</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
I can invoke the sample.message.TestMsg no problem (I don't get a
response, but I think that's correct? Haven't run this using TCPMonitor
yet)
What does the InvocationTargetException usually indicate? I've tried
implementing my service as both:
public void foo(SOAPEnvelope req, SOAPEnvelope resp)
and
public void foo(SOAPEnvelope req, SOAPEnvelope resp) throws
javax.xml.soap.SOAPException
but both produce the same result.
Any thoughts?
Thanks in advance,
Andy
__________________________________________________________
Find your next car at http://autos.yahoo.ca