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