users@jax-rpc.java.net

RE: Server exception when invoking web service using DII

From: Ryan LeCompte <ryan.lecompte_at_pangonetworks.com>
Date: Mon, 1 Nov 2004 16:26:40 -0500

Kathy,
 
Can you provide an example of an operation that has a namespace set? Sorry
for my ignorance regarding WSDL, but I'm not sure exactly how to modify the
test WSDL to specify a namespace for the operation..
 
Thanks!
 
-- Ryan

  _____

From: kathy walsh [mailto:Kathleen.Walsh_at_Sun.COM]
Sent: Monday, November 01, 2004 4:21 PM
To: users_at_jax-rpc.dev.java.net
Subject: Re: Server exception when invoking web service using DII


If you can view the xml stream that is output from both the
stub and the dii client using a tool like tcptunnel or tcpMonitor-
or write one yourself-
By viewing the differences, you may see what is not serializing properly.
In order to tweak the serializer you need to use the -keep option with
wscompile
Based on what you find, review the generated serializer code and examine
look at
the area that you have found that is different on the sent dii xml stream.
Try tweaking that area of code

Another thought is that there is no namespace set on the operation .
Literal web services with dii and dynamic proxies will error if
the namespaces are not set correctly-I would try this first before teaking
the serializer.

Kathy

Ryan LeCompte wrote:


Kathy,
 
Thank you for responding. You mention that I may have to tweak the generated
serializer code from wscompile to make this work with DII. Can you shed a
bit more guidance in how I would go about doing that? What would need to
change?
 
Thank you,
 
-- Ryan

  _____

From: kathy walsh [mailto:Kathleen.Walsh_at_Sun.COM]
Sent: Monday, November 01, 2004 3:50 PM
To: users_at_jax-rpc.dev.java.net
Subject: Re: Server exception when invoking web service using DII


Ryan-

You may have to tweak the serializer code generated from
wscompile in order to use this with a DII client.
Let me know if you need more help with this-
Kathy


Ryan LeCompte wrote:

Hello,
 
I'm having a problem invoking a JAX-RPC web service implementation that is
generated from a custom WSDL file using DII in a JAX-RPC client. I can
invoke this web service using generated stubs without any problems. When I
invoke the remote web service using DII, an exception is generated on the
server. I'm using JWSDP 1.4. I've attempted to write a fairly small "test"
WSDL and JAX-RPC client to demonstrate the problem:
 
I. TestWebService WSDL
 
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="TestWebService"
   targetNamespace="urn:com.test.webservice/wsdl"
   xmlns:tns="urn:com.test.webservice/wsdl"
   xmlns:xsdns="urn:com.test.webservice/types"
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns="http://schemas.xmlsoap.org/wsdl/">
 <types>
  <schema targetNamespace="urn:com.test.webservice/types"
     xmlns:tns="urn:com.test.webservice/types"
     xmlns="http://www.w3.org/2001/XMLSchema">
   <complexType name="tData">
    <sequence>
     <element name="arrayOfData" type="tns:tDatum" nillable="false"
        minOccurs="1" maxOccurs="unbounded"/>
    </sequence>
   </complexType>
   <complexType name="tDatum">
    <sequence>
     <element name="dataOne" type="string" nillable="false"/>
     <element name="dataTwo" type="string" nillable="false"/>
    </sequence>
   </complexType>
   <element name="data" type="tns:tData"/>
  </schema>
 </types>
 
 <message name="TestWebService_handleData">
  <part name="parameters" element="xsdns:data"/>
 </message>
 
 <portType name="TestWebServicePortType">
  <operation name="handleData">
   <input message="tns:TestWebService_handleData"/>
  </operation>
 </portType>
   
 <binding name="TestWebServiceBinding" type="tns:TestWebServicePortType">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
  <operation name="handleData">
   <soap:operation soapAction="TestWebService/handleData"/>
   <input>
    <soap:body use="literal"/>
   </input>
  </operation>
 </binding>
 
 <service name="TestWebService">
  <port name="TestWebServicePort" binding="tns:TestWebServiceBinding">
   <soap:address location="TODO REPLACE_WITH_ACTUAL_URL"/>
  </port>
 </service>
</definitions>
 
II. Test JAX-RPC client using stubs and DII
 
-- note that the server exception is generated only when the DII
Call.invokeOneWay is executed, not the stub call
-- also note that the method registerSerializers() was added since it
appears that the custom serializers must be registered explicitly in the
client code (the register serializer code was essentially copied/pasted from
the auto-generated code from wscompile)
 
public class TestWebServiceClient implements SerializerConstants {
    private static final String SERVICE_URI =
"urn:com.test.webservice/wsdl";
      
    public static void main(String[] args) {
        String STUB_ADDR =
"http://localhost:8080/TestService/TestWebService";
        String DII_ADDR =
"http://localhost:8080/TestService/TestWebService?WSDL";
        
        try {
            TestWebService_Impl serviceImpl = new TestWebService_Impl();
            TestWebServicePortType stub =
(TestWebServicePortType)serviceImpl.getTestWebServicePort();
            ((Stub)stub)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY,
STUB_ADDR);
            
            // Create and send multiple Datum objects via stub.
            TDatum[] data = new TDatum[5];
            for (int i = 0; i < data.length; i++) {
              data[i] = new TDatum();
              data[i].setDataOne("One");
              data[i].setDataTwo("Two");
            }
            stub.handleData(data);
           
            // Create and send multiple Datum objects via DII.
            String BODY_NAMESPACE_VALUE = SERVICE_URI;
            String ENCODING_STYLE_PROPERTY
="javax.xml.rpc.encodingstyle.namespace.uri";
            String serviceName = "TestWebService";
            String portName = "TestWebServicePort";
            Service service = null;
            QName port = null;
            ServiceFactory factory = ServiceFactory.newInstance();
            service = factory.createService(new URL(DII_ADDR), new
QName(BODY_NAMESPACE_VALUE, serviceName));
            
            registerSerializers(service);
            port = new QName(BODY_NAMESPACE_VALUE, portName);
            QName operation = new QName("handleData");
            Call call = service.createCall(port, operation);
            call.setProperty(Call.SOAPACTION_USE_PROPERTY, new
Boolean(true));
            call.setProperty(Call.SOAPACTION_URI_PROPERTY,
"TestWebService/handleData");
            call.setProperty(ENCODING_STYLE_PROPERTY, "");
            call.setProperty(Call.OPERATION_STYLE_PROPERTY, "document");
            Object[] params = new Object[] { new TData(data) };
            call.invokeOneWay(params);
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }
    
    private static void registerSerializers(Service service) {
       TypeMappingRegistry registry = service.getTypeMappingRegistry();
       TypeMapping mapping12 =
registry.getTypeMapping(SOAP12Constants.NS_SOAP_ENCODING);
       TypeMapping mapping =
registry.getTypeMapping(SOAPConstants.NS_SOAP_ENCODING);
       TypeMapping mapping2 = registry.getTypeMapping("");
        
        {
            QName type = new QName("urn:com.test.webservice/types",
"tData");
            CombinedSerializer serializer = new
com.test.webservice.TData_LiteralSerializer(type, "", DONT_ENCODE_TYPE);
            registerSerializer(mapping2,com.test.webservice.TData.class,
type, serializer);
        }
        {
            QName type = new QName("urn:com.test.webservice/types",
"tDatum");
            CombinedSerializer serializer = new
com.test.webservice.TDatum_LiteralSerializer(type, "", DONT_ENCODE_TYPE);
            registerSerializer(mapping2,com.test.webservice.TDatum.class,
type, serializer);
        }
    }
    
     private static void registerSerializer(TypeMapping mapping, Class
javaType, QName xmlType,
        Serializer ser) {
        mapping.register(javaType, xmlType, new
SingletonSerializerFactory(ser),
            new SingletonDeserializerFactory((Deserializer)ser));
    }
    
}
 
III. Server-side exception
 
When I invoke the remote web service using DII, the following exception is
generated on the server:
 
Nov 1, 2004 2:20:24 PM com.sun.xml.rpc.server.StreamingHandler handle
SEVERE: unrecognized operation: {urn:com.test.webservice/types}tData
unrecognized operation: {urn:com.test.webservice/types}tData
        at
com.test.webservice.TestWebServicePortType_Tie.peekFirstBodyElement(T
estWebServicePortType_Tie.java:76)
        at
com.sun.xml.rpc.server.StreamingHandler.handle(StreamingHandler.java:
218)
        at
com.sun.xml.rpc.server.http.JAXRPCServletDelegate.doPost(JAXRPCServle
tDelegate.java:443)
        at
com.sun.xml.rpc.server.http.JAXRPCServlet.doPost(JAXRPCServlet.java:8
6)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:237)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:157)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:214)
        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
        at
org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
ContextValve.java:198)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:152)
        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:137)
        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:117)
        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520) ...... (rest of exception omitted)
 
At first I thought that there was a problem with my WSDL, but that shouldn't
be the case since the stub-based JAX-RPC client code works without any
problems. Also, the DII code doesn't generate any client-side exceptions
when invoked.
 
Any help is much appreciated!
 
Regards,
 
-- Ryan