axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tony Blair <hrh...@yahoo.com>
Subject Re: Here is the solution for you, Tony!
Date Fri, 06 Feb 2004 15:52:41 GMT
Hi Wagh,
 
Where did you get the PublicService2.java and the Request.java?. I am assuming that you got
them from my older posts.I got these files working after talking with Venkatesh 3 days ago.
The ones that I have problem with are the ones that I have pasted on this email such as PublicService3.java
the version of Request.java that takes Collection and the Client.java that expects to receive
a Collection of Param object.
Perhaps if you get a chance please take a look at the ones that I have pasted toward the end
of this email.
 
Thanks,
Tony.


"Wagh, Shrikant" <shrikant.wagh@hp.com> wrote:

Hi Tony Blair,

 

Please take a look at the attached classes, WSDD file, request, response etc…

 

There is nothing wrong with the axis neither any bug. The issue was with your WSDD file. I
wrote it little different way. Method signature etc are same just added the package name and
serializable interface for your Request class.

 

The sample request generated by WebServiceTester tool for the WSDL for your service is attached
at the end of this email together with the WSDD file and the response received from the web
service. I did not use the java client just used WebServiceTester tool to invoke the web service.
If you need client code let me know.

 

Just compile this code and stick those classes in WEB-INF/classes dir. Paste the WSDD entry
in your server-config.wsdd. Restart the tomcat. 

 

Good luck. (By any chance, Are you UK Prime Minister, Mr. Tony Blair??)

 

Shrikant…

HPP/eProfile QA Lead. HP

 

For those who are interested in Web Services testing:

-----------------------------------------------------

I found that WebServiceTester from Optimyz software is a very good tool for testing any types
of web services, and I'm great fan of this tool. It supports all types of web services, and
all simple and complex types and it very usable than any other tool in the market I ever used/evaluated.
It automatically generates the SOAP requests and invokes the intended web services. It can
perform functional, regression and load testing of web services. Result analysis and status
reporting is just wonderful.  I'll highly recommend this tool for testing web services, saves
lots of time and efforts in testing web services. For more information visit http://www.optimyz.com.


 

DISCLAIMER 

================================================================

THESE ARE MY PERSONAL VIEWS/OPINIONS AND DOES NOT REPRESENT HP, AND THE INFORMATION PROVIDED
``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
EVENT SHALL THE I/HP BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS INFORMATION, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE. 

=================================================================

 

Request


POST /axis/services/PublicService2 HTTP/1.1



Content-Type: text/xml; charset=utf-8



Accept: application/soap+xml, application/dime, multipart/related, text/*



User-Agent: WST



Host: 127.0.0.1



Cache-Control: no-cache



Pragma: no-cache



SOAPAction: ""



Content-Length: 814

Connection: close



 

 

<?xml version="1.0" encoding="UTF-8"?>   

   <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns0="http://localhost:8070/axis/services/PublicService2" xmlns:ns1="http://axis.user.net/PublicService2"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     

      <SOAP-ENV:Body>         

         <tns:getSingleBusinessLocation xmlns:tns="http://user.axis">            

            <in0 xsi:type="ns1:Request">               

               <params xsi:type="ns0:Param">                  

                  <name xsi:type="xsd:string">stringData1</name>             
    

                  <value xsi:type="xsd:string"/>               

               </params>            

            </in0>         

         </tns:getSingleBusinessLocation>      

      </SOAP-ENV:Body>   

   </SOAP-ENV:Envelope>

 

 

response


HTTP/1.1 200 OK



Content-Type: text/xml; charset=utf-8



Transfer-Encoding: chunked



Date: Fri, 06 Feb 2004 00:23:12 GMT



Server: Apache-Coyote/1.1



Connection: close



 

 

360



<?xml version="1.0" encoding="UTF-8"?>

   <soapenv:Envelope xmlns: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>  

         <ns1:getSingleBusinessLocationResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://user.axis">   

            <ns1:getSingleBusinessLocationReturn href="#id0"/>  

         </ns1:getSingleBusinessLocationResponse>  

         <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns2:Param" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://localhost:8070/axis/services/PublicService2">
  

            <name xsi:type="xsd:string">LINE_1</name>   

            <value xsi:type="xsd:string">121 River Street</value>  

         </multiRef> 

      </soapenv:Body>

   </soapenv:Envelope>

0





 

WSDD File entry


  <service name="PublicService2" provider="java:RPC">

   <parameter name="allowedMethods" value="*"/>

   <parameter name="wsdlPortType" value="PublicService2"/>

   <parameter name="className" value="axis.user.PublicService2"/>

   <parameter name="wsdlTargetNamespace" value="http://localhost:8070/axis/services/PublicService2"/>

   <typeMapping deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
qname="ns101:Request" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" type="java:axis.user.Request"
xmlns:ns101="http://axis.user.net/PublicService2"/>

   <typeMapping deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
qname="ns102:Param" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" type="java:axis.user.Param"
xmlns:ns102="http://localhost:8070/axis/services/PublicService2"/>

  </service>

 

 

 

-----Original Message-----
From: Tony Blair [mailto:hrh747@yahoo.com] 
Sent: Thursday, February 05, 2004 8:18 AM
To: axis-user@ws.apache.org
Subject: Re: SimpleDeserializer error

 

Hi Venkatesh,


 


Thanks for the suggestion. I slightly modified my code from yesterday where my bean takes
a Collection and my service also returns a Collection. Based on the error I get I am not sure
if the ser/deser are the problem. Here is the error and thanks for all the help you can give
me.


 


-----------error msg-------------


SEVERE: Exception:
org.xml.sax.SAXException: Bad types (class [Ljava.lang.Object; -> class apacheax
is.Param)
        at org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:311)
        at org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
rializationContextImpl.java:963)
        at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
va:198)
        at org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
t.java:722)
        at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233)
        at org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)
        at org.apache.axis.client.Call.invoke(Call.java:2272)
        at org.apache.axis.client.Call.invoke(Call.java:2171)
        at org.apache.axis.client.Call.invoke(Call.java:1691)
        at apacheaxis.Client.main(Client.java:41)
Error : org.xml.sax.SAXException: Bad types (class [Ljava.lang.Object; -> class
apacheaxis.Param)


 


-------------------The first bean------------------


public class Request  
{
   / ********** this bean now handles collections*************/
    private Collection params=null
    
    public Collection getParams()
    { return params; }
    public void setParams(Collection data)
    { params=data; }
    
}
------------- The 2nd bean ------------


public class Param implements java.io.Serializable
{
/********** this class remains unchanged **************/    
    private String name=null;
    private Object value=null;
    public String getName()
    { return name; }
    public void setName(String data)
    { name = data; }
    
    public Object getValue()
    { return value; }
    public void setValue(Object data)
    { value=data; }
}


-------------- The service --------------


public class PublicService3
{


  /********Service now is returning Collection *******/
    public Collection getSeveralBusinessLocation(Request req){


        Collection busLoc = new ArrayList(2);


        Param line1= new Param();
        line1.setName("LINE_1");
        line1.setValue("121 River Street");
        busLoc.add(line1);


        Param name= new Param();
        name.setName("BUSINESS_NAME");
        name.setValue("Marsh");
        busLoc.add(name);



        return busLoc;
    } 
}


------------Client ---------


public class Client
{
    public static void main(String [] args) throws Exception
    {
        Options options = new Options(args);
        
        Request req = new Request();
        
        Service  service = new Service();
        Call     call    = (Call) service.createCall();
        QName    qn      = new QName( "urn:PublicService3", "Request" );


        call.registerTypeMapping(Request.class, qn,
                      new org.apache.axis.encoding.ser.BeanSerializerFactory(Request.class,
qn),        
                      new org.apache.axis.encoding.ser.BeanDeserializerFactory(Request.class,
qn));


        call.registerTypeMapping(Param.class, qn,
                      new org.apache.axis.encoding.ser.BeanSerializerFactory(Param.class,
qn),        
                      new org.apache.axis.encoding.ser.BeanDeserializerFactory(Param.class,
qn));        


        Collection result=null;
        try {
            call.setTargetEndpointAddress( new java.net.URL(options.getURL()) );
            call.setOperationName( new QName("PublicService3", "getSeveralBusinessLocation")
);
            call.addParameter( "arg1", qn, ParameterMode.IN );
            call.setReturnClass(Param.class);
            result = (ArrayList) call.invoke( new Object[] { req } );
        } catch (AxisFault fault) {
          String  error = "Error : " + fault.toString();
          System.out.println(error);
        }
        System.out.println("Name               Value");
        System.out.println("------------------------");
        Iterator itr = result.iterator();
        while(itr.hasNext()){
            Param p = (Param)itr.next();
            String name = p.getName();
            String value = (String)p.getValue();
            System.out.println(name+"     &nbs p; "+value);


        }
    }
}


-----------deploy.wsdd----------------


<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
    <service name="PublicService3" provider="java:RPC" style="wrapped">
        <parameter name="className" value="apacheaxis.PublicService3"/>
        <parameter name="allowedMethods" value="getSeveralBusinessLocation"/>
        <beanMapping qname="myNS:Request" xmlns:myNS="urn:PublicService3" languageSpecificType="java:apacheaxis.Request"/>
        <beanMapping qname="myNS:Param" xmlns:myNS="urn:PublicService3" languageSpecificType="java:apacheaxis.Param"/>
        <typeMapping qname="myNS:Param" xmlns:myNS="urn:PublicService3" languageSpecificType="java:apacheaxis.Param"
             deserializer="apacheaxis.ParamDeserFactory"/>
    </service>
</deployment>


 


Thanks,


Tony.



Venkatesh Kancharla <venkatesh@strandgenomics.com> wrote:


Have a look at org.apache.axis.encoding.ser package. It contains all the
serializers and deserializers for some collecion objects.

On Wed, 4 Feb 2004, Tony Blair wrote:

> Venkatesh,
> 
> Does Axis allow beans to have Collections as their data member?
> 
> Thanks,
> Tony.
> 
> Venkatesh Kancharla wrote:
> > 
> > Error : org.xml.sax.SAXException: SimpleDeserializer encountered a child element
> > , which is NOT expected, in something it was trying to deserialize.
> > 
> > My client is invoking a call to the service and pass it a bean that has a complex
type as a data member. Should I post the code and deploy.wsdd?
> 
> is your complex object a bean? you can only pass beans ( it should have
> setter/getter methods for all of it s instance variables)
> 
> 
> > 
> > Thanks in advance.
> > 
> > 
> > ---------------------------------
> > Do you Yahoo!?
> > Yahoo! SiteBuilder - Free web site building tool. Try it!
> 
> 
> ---------------------------------
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!

---------------------------------


Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online



---------------------------------
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online
Mime
View raw message