users@jax-rpc.java.net

RE: Need help...Added some Info

From: Velidanda Srinivas <srinivas.velidanda_at_singularity.co.uk>
Date: Mon, 9 Jan 2006 05:38:02 -0000

Hi,
 
Thanks for the Reply..
Can you please let me know how to work with arrays, I tried working with
arrays before going to java.util.Collection.
 
I could not succeed.
Possibly If I can get a sample work around to return arrays, I would be
thankful to you.
 
and also let me know if future versions of JAX RPC going to support Java Non
Builtin types like Collection etc.,
 
 
Srinivas.

-----Original Message-----
From: Anne Thomas Manes [mailto:atmanes_at_gmail.com]
Sent: Friday, January 06, 2006 9:32 PM
To: users_at_jax-rpc.dev.java.net
Subject: Re: Need help...Added some Info


IIRC, JAX-RPC DII does not support collections.

For interoperability reasons, it's a really bad idea to expose collections
through a web services interface. You should convert your collections to
arrays. You should also switch to document/literal.

Anne


On 1/6/06, Velidanda Srinivas < srinivas.velidanda_at_singularity.co.uk
<mailto:srinivas.velidanda_at_singularity.co.uk> > wrote:

Hi,


I want to add something to my earlier mail here that

Following clients are working fine and I am able to see the output
1.Test client from Weblogic admin console
2.Stub Client app using the stubs generated as part of client jar
3.SOAP client app created using JAXM API

I have problem working with JAX RPC Dynamic Client while getting
java.util.Collection at client side.

Please let me know how to fix this.

--I am using Weblogic Server 8.1 with SP3
-- CLASSPATH FOR THIS APPLICATION
.;C:\bea\weblogic81\server\lib\webserviceclient.jar;C:\bea\weblogic81\server

\lib\webservices.jar;.\WorkQueueService-client.jar;\WorkQueueService.jar;C:\
bea\jdk142_04\lib\tools.jar;C:\bea\WEBLOG~1\common\eval\pointbase\lib\pbserv
er44.jar;C:\bea\WEBLOG~1\common\eval\pointbase\lib\pbclient44.jar;C:\bea\jdk

142_04\jre\lib\rt.jar;

Following is my client code and the errors while running the same.



/*******************************************************
AllClient.java
*******************************************************/
package service.client;
import javax.xml.soap.SOAPElementFactory;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import javax.xml.rpc.soap.SOAPFaultException;
import java.rmi.RemoteException ;
import javax.xml.rpc.encoding.XMLType;

import javax.xml.soap.SOAPConstants;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Service;
import javax.xml.rpc.Call;
import javax.xml.rpc.ParameterMode ;

import javax.xml.namespace.QName;

import javax.xml.rpc.encoding.TypeMapping;
import javax.xml.rpc.encoding.TypeMappingRegistry;

import ejb.WQDefInfo;
import service.WQDefInfoCodec;

import java.util.Collection;
import java.util.Vector;
import java.util.Iterator;
import java.util.ArrayList;

import weblogic.xml.schema.binding.internal.builtin.JavaUtilCollectionCodec;
import weblogic.xml.schema.binding.internal.builtin.JavaUtilVectorCodec ;
import weblogic.xml.schema.binding.internal.builtin.JavaUtilArrayListCodec;


/* CLASSPATH FOR THIS APPLICATION
.;C:\bea\weblogic81\server\lib\webserviceclient.jar;C:\bea\weblogic81\server
\lib\webservices.jar;.\WorkQueueService-
client.jar;\WorkQueueService.jar;C:\
bea\jdk142_04\lib\tools.jar;C:\bea\WEBLOG~1\common\eval\pointbase\lib\pbserv
er44.jar;C:\bea\WEBLOG~1\common\eval\pointbase\lib\pbclient44.jar;C:\bea\jdk
142_04\jre\lib\rt.jar;
*/

public class AllClient{

        ServiceFactory factory;
        String targetNamespace;
        QName serviceName;
        QName portName;
        Service service;
        TypeMapping mapping=null;
        TypeMappingRegistry registry;
        Call call;
        SOAPElementFactory soapFactory;


  public static void main( String[] args ){
    try{
      new AllClient().invoke();
    }catch( Exception e ){
      e.printStackTrace();
    }
  }
        private void invoke() throws Exception
        {
                //Common Settings

System.setProperty("javax.xml.soap.MessageFactory","
weblogic.webservice.core
.soap.MessageFactoryImpl");
                System.setProperty( "javax.xml.rpc.ServiceFactory",
"weblogic.webservice.core.rpc.ServiceFactoryImpl" );
                factory = ServiceFactory.newInstance();
                targetNamespace = " http://localhost:7001/WorkQueueService/
<http://localhost:7001/WorkQueueService/> ";

                serviceName = new QName( targetNamespace, "WorkQueueService"
);
                service = factory.createService( serviceName );

                registry = service.getTypeMappingRegistry();
                mapping =
registry.getTypeMapping(SOAPConstants.URI_NS_SOAP_ENCODING );
                call = service.createCall();
                portName = new QName( targetNamespace,
"WorkQueueServicePort" );
                call.setPortTypeName( portName );

call.setTargetEndpointAddress("
http://localhost:7001/WorkQueueService/WorkQu
<http://localhost:7001/WorkQueueService/WorkQu>
eueService");
                //Common Settings

                // Type Mappings used

                //mapping.register(WQDefInfo.class,new
QName(" http://localhost:7001/WorkQueueService/
<http://localhost:7001/WorkQueueService/> ", "WQDefInfo" ),new
WQDefInfoCodec(), new WQDefInfoCodec());
                //mapping.register(Collection.class,new
QName(targetNamespace,"Collection" ),new JavaUtilCollectionCodec(), new
JavaUtilCollectionCodec());
                //mapping.register(Vector.class,new QName(
" http://localhost:7001/WorkQueueService/
<http://localhost:7001/WorkQueueService/> ", "Vector" ),new
JavaUtilVectorCodec(), new JavaUtilVectorCodec());
                //mapping.register( ArrayList.class,new
QName(" http://localhost:7001/WorkQueueService/
<http://localhost:7001/WorkQueueService/> ", "ArrayList" ),new
JavaUtilArrayListCodec(), new JavaUtilArrayListCodec());

                soapFactory = SOAPElementFactory.newInstance();


                //log("Invoking Web Service..method..getWQDef....");
                //getWQDef(); //returns WQDefInfo object

                log("Invoking Web
Service..method..getAllWQDefinitions....");
                getAllWQDefinitions(); //returns java.util.Collection

                //log("Invoking Web Service..method..getAllDefs....");
                //getAllDefs(); //returns java.util.Collection

        }
        private void getAllWQDefinitions()
        {
                call.removeAllParameters();
                mapping.register(WQDefInfo.class,new QName(
" http://localhost:7001/WorkQueueService/
<http://localhost:7001/WorkQueueService/> ", "WQDefInfo" ),new
WQDefInfoCodec(), new WQDefInfoCodec());
                mapping.register (Collection.class,new QName(
" http://localhost:7001/WorkQueueService/
<http://localhost:7001/WorkQueueService/> ", "Collection" ),new
JavaUtilCollectionCodec(), new JavaUtilCollectionCodec());
                 call.removeAllParameters();
                QName operationName = new QName(
" http://localhost:7001/WorkQueueService/
<http://localhost:7001/WorkQueueService/> ", "getAllWQDefinitions" );
                call.setOperationName(operationName);
                call.setReturnType(new QName(targetNamespace,"Collection"));

                Object[] params={};
                Collection col=(Collection)callService(call,params);

                /*Iterator defIte=col.iterator();
            int defObj=0;
                while (defIte.hasNext())
                {
                         defObj++;
                         WQDefInfo w=(WQDefInfo)defIte.next();
                         log("Record ............."+defObj);
                         log("Definition ID :"+w.getDefId());
                         log("Category ID :"+w.getCatId());
                         log("Definition Name :"+w.getDefName());
                         log("Changed Date :"+w.getDefId());
                         log();
                }*/
                log("Got "+col.size()+" WQDefInfo Objects");
        }
        private void getWQDef()
        {

                call.removeAllParameters();

call.addParameter("defId",XMLType.XSD_STRING
,String.class,ParameterMode.IN);
                mapping.register(WQDefInfo.class,new QName(
" http://localhost:7001/WorkQueueService/
<http://localhost:7001/WorkQueueService/> ", "WQDefInfo" ),new
WQDefInfoCodec(), new WQDefInfoCodec());
                QName operationName = new QName(
" http://localhost:7001/WorkQueueService/
<http://localhost:7001/WorkQueueService/> ", "getWQDef" );
                call.setOperationName(operationName);
                call.setReturnType (new QName(
" http://localhost:7001/WorkQueueService/","WQDefInfo"))
<http://localhost:7001/WorkQueueService/> ;
                Object[] params={"1"};
                WQDefInfo def=(WQDefInfo)callService(call,params);
                log("Server Reply........... ");
                log(def.toString());

                /*log("Category Id : "+def.getCatId());
                log("Definition Id : "+def.getDefId());
                log("Definition Name : "+def.getDefName());
                log("Change Date : "+def.getChangeDate());*/
        }
        private void addWQDefinition()
        {
                call.removeAllParameters();

call.addParameter("defId",XMLType.XSD_STRING,String.class
,ParameterMode.IN);

call.addParameter("catId",XMLType.XSD_STRING,String.class,ParameterMode.IN);

call.addParameter("defName",XMLType.XSD_STRING,String.class,ParameterMode.IN
);
                QName operationName = new QName(
" http://localhost:7001/WorkQueueService/
<http://localhost:7001/WorkQueueService/> ", "addWQDefinition" );
                call.setOperationName(operationName);
                call.setReturnType (XMLType.XSD_STRING);

                Object[] params={"67","1","AllClients"};
                String s=(String)callService(call,params);
                log(s);
        }

        private Object callService(Call call,Object[] actualArgs)
        {
                Object result=null;
                try
                {
                        result =call.invoke(actualArgs);
                } // try
                catch(SOAPFaultException ex)
                {
                        System.out.println("[Client] Fault Detail : " +
ex.getDetail().toString());
                        System.out.println("[Client] Fault Actor : " +
ex.getFaultActor());
                        System.out.println("[Client] Fault String : " +
ex.getFaultString());
                        ex.printStackTrace();
                        }

                        catch(RemoteException ex)
                        {
                                if (ex.getCause() instanceof
SOAPFaultException)
                                {
                                        SOAPFaultException fault =
(SOAPFaultException)ex.getCause();
                                        System.out.println("[Client] Fault
Detail : " + fault.getDetail().toString());
                                        System.out.println("[Client] Fault
Actor : " + fault.getFaultActor());
                                        System.out.println("[Client] Fault
String : " + fault.getFaultString());
                                }
                        System.out.println("[Client] Exception stack trace
:");
                        ex.printStackTrace();
                        }
                        return result;
        }

        private void log(String s)
        {
                System.out.println(s);
        }
}
/***************************************************************************
****/

Following are the errors displayed while running the client.



/************************************************/
Error at command prompt
/************************************************/

C:\Clients\rpcclient>java service.client.AllClient
Invoking Web Service..method..getAllWQDefinitions....
javax.xml.rpc.JAXRPCException: failed to invoke operation
'getAllWQDefinitions'
due to an error in the soap layer (SAAJ); nested exception is:
Message[failed to
deserialize xml:weblogic.xml.schema.binding.DeserializationException: type
mapp
ing lookup failure on type=['java:ejb']:n1:WQDefInfo TypeMapping=TYPEMAPPING
SIZ
E=2
ENTRY 1:
class: java.util.Collection
xsd_type: [' http://localhost:7001/WorkQueueService/']:Collection
<http://localhost:7001/WorkQueueService/']:Collection>
ser:
weblogic.xml.schema.binding.internal.builtin.JavaUtilCollectionCodec @
d02b51
deser:
weblogic.xml.schema.binding.internal.builtin.JavaUtilCollectionCodec@
cbf30e
ENTRY 2:
class: ejb.WQDefInfo
xsd_type: [' <http://localhost:7001/WorkQueueService/']:WQDefInfo>
http://localhost:7001/WorkQueueService/']:WQDefInfo
ser: service.WQDefInfoCodec_at_1c247a0
deser: service.WQDefInfoCodec_at_1ec6696
]StackTrace[

javax.xml.soap.SOAPException: failed to deserialize
xml:weblogic.xml.schema.bind
ing.DeserializationException: type mapping lookup failure on
type=['java:ejb']:n
1:WQDefInfo TypeMapping=TYPEMAPPING SIZE=2
ENTRY 1:
class: java.util.Collection
xsd_type: [' http://localhost:7001/WorkQueueService/']:Collection
<http://localhost:7001/WorkQueueService/']:Collection>
ser:
weblogic.xml.schema.binding.internal.builtin.JavaUtilCollectionCodec@
d02b51
deser:
weblogic.xml.schema.binding.internal.builtin.JavaUtilCollectionCodec@
cbf30e
ENTRY 2:
class: ejb.WQDefInfo
xsd_type: [' http://localhost:7001/WorkQueueService/']:WQDefInfo
<http://localhost:7001/WorkQueueService/']:WQDefInfo>
ser: service.WQDefInfoCodec_at_1c247a0
deser: service.WQDefInfoCodec_at_1ec6696

        at weblogic.webservice.core.DefaultPart.toJava(DefaultPart.java:389)
        at
weblogic.webservice.core.DefaultMessage.toJava (DefaultMessage.java:48
4)
        at
weblogic.webservice.core.ClientDispatcher.receive(ClientDispatcher.ja
va:325)
        at
weblogic.webservice.core.ClientDispatcher.dispatch(ClientDispatcher.j
ava:144)
        at
weblogic.webservice.core.DefaultOperation.invoke(DefaultOperation.jav
a:457)
        at
weblogic.webservice.core.DefaultOperation.invoke(DefaultOperation.jav
a:443)
        at weblogic.webservice.core.rpc.CallImpl.invoke (CallImpl.java:558)
        at weblogic.webservice.core.rpc.CallImpl.invoke(CallImpl.java:411)
        at service.client.AllClient.callService(AllClient.java:161)
        at service.client.AllClient.getAllWQDefinitions (AllClient.java:105)
        at service.client.AllClient.invoke(AllClient.java:89)
        at service.client.AllClient.main(AllClient.java:52)
Caused by: weblogic.xml.schema.binding.DeserializationException: type
mapping lo
okup failure on type=['java:ejb']:n1:WQDefInfo TypeMapping=TYPEMAPPING
SIZE=2
ENTRY 1:
class: java.util.Collection
xsd_type: [' <http://localhost:7001/WorkQueueService/']:Collection>
http://localhost:7001/WorkQueueService/']:Collection
ser:
weblogic.xml.schema.binding.internal.builtin.JavaUtilCollectionCodec@
d02b51
deser:
weblogic.xml.schema.binding.internal.builtin.JavaUtilCollectionCodec @
cbf30e
ENTRY 2:
class: ejb.WQDefInfo
xsd_type: [' http://localhost:7001/WorkQueueService/']:WQDefInfo
<http://localhost:7001/WorkQueueService/']:WQDefInfo>
ser: service.WQDefInfoCodec_at_1c247a0
deser: service.WQDefInfoCodec_at_1ec6696

        at
weblogic.xml.schema.binding.RuntimeUtils.lookup_deserializer(RuntimeU
tils.java:443)
        at
weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec.deserialize (
XSDAnyCodec.java:106)
        at
weblogic.xml.schema.binding.SoapArrayCodecBase$EntryIterator.getNextO
bject(SoapArrayCodecBase.java:751)
        at
weblogic.xml.schema.binding.SoapArrayCodecBase$EntryIterator .<init>(S
oapArrayCodecBase.java:707)
        at
weblogic.xml.schema.binding.SoapArrayCodecBase.deserialize(SoapArrayC
odecBase.java:288)
        at
weblogic.xml.schema.binding.RuntimeUtils.invoke_deserializer (RuntimeU
tils.java:428)
        at
weblogic.xml.schema.binding.RuntimeUtils.invoke_deserializer(RuntimeU
tils.java:328)
        at weblogic.webservice.core.DefaultPart.toJava(DefaultPart.java:384)
        ... 11 more
]

        at weblogic.webservice.core.rpc.CallImpl.invoke(CallImpl.java:578)
        at weblogic.webservice.core.rpc.CallImpl.invoke(CallImpl.java:411)
        at service.client.AllClient.callService(AllClient.java :161)
        at service.client.AllClient.getAllWQDefinitions(AllClient.java:105)
        at service.client.AllClient.invoke(AllClient.java:89)
        at service.client.AllClient.main(AllClient.java:52)

/***************************************************************************

*******************************/

Enclosing client jar file created using clientgen ant task.

<<WorkQueueService-client.jar>>


thanks,
Srinivas.



________________________________________________________________________
This e-mail has been scanned for all viruses by MessageLabs.
________________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
<mailto:users-unsubscribe_at_jax-rpc.dev.java.net>
For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
<mailto:users-help_at_jax-rpc.dev.java.net>






________________________________________________________________________
This e-mail has been scanned for all viruses by MessageLabs.
________________________________________________________________________




________________________________________________________________________
This e-mail has been scanned for all viruses by MessageLabs.
________________________________________________________________________