users@jax-rpc.java.net

Re: Connecting JAXM Client to JAXRPC service

From: Anne Thomas Manes <anne_at_MANES.NET>
Date: Fri, 20 Sep 2002 10:31:39 -0400

Vibhor,

You should be able to invoke a JAX-RPC service from a JAXM client.

JAX-RPC is telling you that it doesn't know how to interpret the <sayHello>
operation -- most likely because you haven't told the JAX-RPC server where
to find information about the <sayHello> operation.

It's impossible to definitively diagnose the problem without looking at the
WSDL file for the JAX-RPC service, but the most obvious potential problem
that I see is that you haven't specified a namespace for the <sayHello>
element. I'd recommend that you define a namespace that points to the WSDL
file for the service you're trying to reach and qualify the <sayHello> and
<s> elements using this namespace, e.g.:

<sayHello xmlns="http://wsdlurl"
 soap-env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s xsi:type="xsd:string">Duke</s>
</sayHello>

But you also want to check to make sure that the WSDL actually defines an
operation called <sayHello> and that it passes a message containing a part
called <s> and that the message should be encoded using SOAP encoding.

Most SOAP implementations are now WSDL-aware. Apache SOAP and JAXM are not.
You don't need to specify the WSDL file when talking to Apache SOAP -- but
you did need to specify the service name using a namespace (<sayHello
xmlns="urn:TestHello">). With a WSDL-aware SOAP implementation, that
namespace should point to the service's WSDL file. A WSDL-aware SOAP
implementation uses the WSDL file to identify and process the request.

The format of your message is always determined by the service, not by the
client. In most situations, the format is described by a WSDL document. If
you're using a WSDL-aware client, then you don't need to concern yourself
with figuring out the proper format for a specific service implementation.
The WSDL client tool will generate a client proxy for you, and the proxy
marshals your requests automatically.

JAX-RPC supports a dynamic proxy, which gives you tremendous flexibility and
interoperability. It dynamically binds the client to the service at runtime
using the WSDL file. Using a single client interface, you can connect to any
service implementation that implements the same service interface (as
defined by a WSDL <portType <operation/>/>). The dynamic binding
automatically selects the appropriate protocols (SOAP 1.1 | SOAP 1.2, RPC |
Document, Literal | Encoded, HTTP | SMTP | JMS) at runtime based on the
<binding> specified in the WSDL document, and automatically marshals the
message based on the <portType> and <message> elements in the WSDL document.
Hence, using a single client application, you can access any number of
different service implementations without recoding or recompilation. You
simply point the client to a different WSDL file at runtime.

Best regards,
Anne

> -----Original Message-----
> From: Public discussion on JAX-RPC
> [mailto:JAXRPC-INTEREST_at_JAVA.SUN.COM]On Behalf Of vibhor sharma
> Sent: Friday, September 20, 2002 8:58 AM
> To: JAXRPC-INTEREST_at_JAVA.SUN.COM
> Subject: Connecting JAXM Client to JAXRPC service
>
>
> Hi,
> I'm getting the following error when i'm trying to connect to a
> JAXRPC service through a JAXM client. Is it a compulsion to invoke the
> JAXRPC service through a JAXRPC client only?
>
> Request :
> <?xml version="1.0" encoding="UTF-8"?>
> <soap-env:Envelope
> xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/1999/XMLSchema">
> <soap-env:Header/><soap -env:Body>
> <sayHello
> soap-env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
> <s xsi:type="xsd:string">Duke</s>
> </sayHello>
> </soap-env:Body>
> </soap-env:Envelope>
>
> Response:
> <?xml version="1.0" encoding="UTF-8"?>
> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:ns0="http://com.test/types/MyHello"
> env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
> <env:Body>
> <env:Fault>
> <faultcode>env:Server</faultcode>
> <faultstring>Internal Server Error (unrecognized operation:
> sayHello)</faultstring>
> </env:Fault>
> </env:Body>
> </env:Envelope>
>
> I have been succesfully able to communicate from a JAXM client to a Soap
> Service but how come we get this error in this case. If the utlimate
> request is a SOAP over HTTP then how come they differ for different
> implementations. Why do we have so many interoperability issues when we
> follow the same protocol and transport layer. The API's are just to help
> you create those request and present you with different mechanisms of
> doing the same thing(SOAP/HTTP).
> Please suggest if i'm making a mistake while dispatching the request.
> How do we identify a unique service on a JAXRPC server? on Apache SOAP
> we use the URN to identify the unique service as follows :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <soap-env:Envelope
> xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
> <soap-env:Header/>
> <soap-env:Body>
> <sayHello xmlns="urn:TestHello">
> <s>Duke!</s>
> </sayHello>
> </soap-env:Body>
> </soap-env:Envelope>
>
> Regards
> Vibhor
>