Hy. I decided to write this e-mail because my earlier message was far from Axis, so read this please.
Example of service that use Person.java: /* * * Copyright (c) 2005 Siemens SBS SOL, Poland. All rights reserved. * * www.sbs.siemens.pl * * File: Person.java * Date: 2005-09-11 */ package webservices.rpc; import java.lang.reflect.Field; import tests.PrinterUtil; /** * @author <a href="mailto:[EMAIL PROTECTED]">Piotr Chojniak</a> * */ public class Person { public Person() { } public Person(String fName, String sName) { this.firstName = fName; this.secondName = sName; } public String firstName; public String secondName; public Person father; public Person mother; public Person getFather() { return this.father; } public void setFather(Person father) { this.father = father; } public Person getMother() { return this.mother; } public void setMother(Person mother) { this.mother = mother; } public String getFirstName() { return this.firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getSecondName() { return this.secondName; } public void setSecondName(String secoundName) { this.secondName = secoundName; } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { PrinterUtil.print(this); return ""; } } Hard way: /* * * Copyright (c) 2005 Siemens SBS SOL, Poland. All rights reserved. * * www.sbs.siemens.pl * * File: PersonSerializer.java * Date: 2005-09-11 */ package webservices.rpc; import java.io.IOException; import javax.xml.namespace.QName; import org.apache.axis.encoding.SerializationContext; import org.apache.axis.encoding.Serializer; import org.apache.axis.wsdl.fromJava.Types; import org.apache.xerces.dom.AttrImpl; import org.w3c.dom.Element; import org.xml.sax.Attributes; import org.xml.sax.helpers.AttributeListImpl; import org.xml.sax.helpers.AttributesImpl; /** * @author <a href="mailto:[EMAIL PROTECTED]">Piotr Chojniak</a> * */ public class PersonSerializer implements Serializer { public void serialize(QName name, Attributes attributes, Object value, SerializationContext context) throws IOException { // TODO Auto-generated method stub if (!(value instanceof Person)) throw new IOException("Can't serialize a " + value.getClass().getName() + " with a DataSerializer."); Person p = (Person) value; context.startElement(name, attributes); context.serialize(new QName("", "firstName"), null, p.getFirstName()); context.serialize(new QName("", "secondName"), null, p.getSecondName()); context.serialize(new QName("", "father"), null, p.getFather()); context.serialize(new QName("", "mother"), null, p.getMother()); context.endElement(); } public Element writeSchema(Class arg0, Types arg1) throws Exception { // TODO Auto-generated method stub return null; } public String getMechanismType() { // TODO Auto-generated method stub return null; } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub } } //end Request: <?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:findParents soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="HelloService"> <ns1:arg0 href="#id0" /> </ns1:findParents> <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="Person" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> <firstName xsi:type="soapenc:string">Piotr</firstName> <secondName xsi:type="soapenc:string">Chojniak</secondName> <father xsi:nil="true" /> <mother xsi:nil="true" /> </multiRef> </soapenv:Body> </soapenv:Envelope> And "hard way " response: <?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:findParentsResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="HelloService"> <findParentsReturn href="#id0" /> </ns1:findParentsResponse> <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="Person" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> <firstName xsi:type="soapenc:string">Piotr</firstName> <secondName xsi:type="soapenc:string">Chojniak</secondName> <father href="#id1" /> <mother href="#id2" /> </multiRef> <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="Person" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> <firstName xsi:type="soapenc:string">mother</firstName> <secondName xsi:type="soapenc:string">Chojniak</secondName> <father xsi:nil="true" /> <mother xsi:nil="true" /> </multiRef> <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="Person" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> <firstName xsi:type="soapenc:string">father</firstName> <secondName xsi:type="soapenc:string">Chojniak</secondName> <father xsi:nil="true" /> <mother xsi:nil="true" /> </multiRef> </soapenv:Body> </soapenv:Envelope> BETTER WAY is: /* * * Copyright (c) 2005 Siemens SBS SOL, Poland. All rights reserved. * * www.sbs.siemens.pl * * File: PersonSerializer.java * Date: 2005-09-11 */ package webservices.rpc; import java.io.IOException; import javax.xml.namespace.QName; import org.apache.axis.encoding.SerializationContext; import org.apache.axis.encoding.Serializer; import org.apache.axis.wsdl.fromJava.Types; import org.apache.xerces.dom.AttrImpl; import org.w3c.dom.Element; import org.xml.sax.Attributes; import org.xml.sax.helpers.AttributeListImpl; import org.xml.sax.helpers.AttributesImpl; /** * @author <a href="mailto:[EMAIL PROTECTED]">Piotr Chojniak</a> * */ public class PersonSerializer implements Serializer { public void serialize(QName name, Attributes attributes, Object value, SerializationContext context) throws IOException { // TODO Auto-generated method stub if (!(value instanceof Person)) throw new IOException("Can't serialize a " + value.getClass().getName() + " with a DataSerializer."); Person p = (Person) value; AttributesImpl attr = new AttributesImpl(attributes); attr.addAttribute("", "firstName", "", "", p.getFirstName()); attr.addAttribute("", "secondName", "", "", p.getSecondName()); context.startElement(name, attr); context.serialize(new QName("", "father"), null, p.getFather()); context.serialize(new QName("", "mother"), null, p.getMother()); context.endElement(); } public Element writeSchema(Class arg0, Types arg1) throws Exception { // TODO Auto-generated method stub return null; } public String getMechanismType() { // TODO Auto-generated method stub return null; } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub } } Request: <?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 :findParents soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="HelloService"><ns1:arg0 href="#id0"/></ns1:findParents><multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" firstName="Piotr" secondName="Chojniak" xsi:type="Person" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"><father xsi:nil="true"/><mother xsi:nil="true"/></multiRef></soapenv:Body></soapenv:Envelope> Response: <?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 :findParentsResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="HelloService"><findParentsReturn href="#id0"/></ns1:findParentsResponse><multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" firstName="" secondName="" xsi:type="Person" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"><father href="#id1"/><mother href="#id2"/></multiRef><multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" firstName="mother" secondName="" xsi:type="Person" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"><father xsi:nil="true"/><mother xsi:nil="true"/></multiRef><multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" firstName="father" secondName="" xsi:type="Person" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"><father xsi:nil="true"/><mother xsi:nil="true"/></multiRef></soapenv:Body></soapenv:Envelope> Simple HelloService package webservices.rpc; import java.util.Hashtable; import org.apache.axis.client.AdminClient; /** * @author pchojniak */ public class HelloService { public String sayHello(String user) { return "HelloService " + user; } public Person findParents(Person p) { p.father = new Person("father", p.secondName); p.mother = new Person("mother", p.secondName); return p; } public String getVersion() { return "v1.0"; } } You need also PersonDeserializar and both Serializer and Deserializer Factories :) Deploy.wsdd: <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <service name="SayHelloService" provider="java:RPC"> <parameter name="className" value="webservices.rpc.HelloService" /> <parameter name="allowedMethods" value="*" /> <typeMapping qname="Person" type="java:webservices.rpc.Person" serializer="webservices.rpc.PersonSerializerFactory" deserializer="webservices.rpc.PersonDeserializerFactory" /> </service> </deployment> I hope it will solve your problem... waiting for your tests :) -----Original Message----- From: Rutherford, Matthew [mailto:[EMAIL PROTECTED] Sent: Friday, January 27, 2006 4:24 PM To: '[email protected]' Subject: RE: WebService performance tweaking Axis 1.3 Wouldn't be able to put up the code; its populated with proprietary data from a database of ours -----Original Message----- From: Davanum Srinivas [mailto:[EMAIL PROTECTED] Sent: 27 January 2006 14:30 To: [email protected] Subject: Re: WebService performance tweaking Are u using Axis2? Am looking for such tests. please open a jira issue with your wsdl and the test code (for constructing your complicated object). thanks, dims On 1/27/06, Rutherford, Matthew <[EMAIL PROTECTED]> wrote: > > Hi > I have a doc/lit web service that currently sends a return object that > looks like this: > return object (complex type) > | > -complextype1[] > | > -String > -long > -complextype2[] > | > -String > -long > -complextype3[] > | > -long > -String > -long > -complextype2[] > > When sending a return object to the ws client, with around 100 > elements in > complextype1 and about 5 on average in both complextype2 and > complextype3, the call takes about 8-10 mins to complete, with my java > client (256meg jvm) taking up 98% of the cpu during this time (which I > guess is doing deserializing of the returned soap msg) > > Is there any best practice/advice/resources for reducing the > performance hit? > > Matthew Rutherford > Digital Markets - Research team > Dresdner Kleinwort Wasserstein > > +44 (0) 20 7475 2523 > > > ---------------------------------------------------------------------- > ---------- The information contained herein is confidential and is > intended solely for the addressee. Access by any other party is > unauthorised without the express written permission of the sender. If > you are not the intended recipient, please contact the sender either > via the company switchboard on +44 (0)20 7623 8000, or via e-mail > return. If you have received this e-mail in error or wish to read our > e-mail disclaimer statement and monitoring policy, please refer to > http://www.drkw.com/disc/email/ or contact the sender. 3166 > ---------------------------------------------------------------------- > ---------- > -- Davanum Srinivas : http://wso2.com/blogs/ ------ ------------------------------------------------------------------------ -------- The information contained herein is confidential and is intended solely for the addressee. Access by any other party is unauthorised without the express written permission of the sender. If you are not the intended recipient, please contact the sender either via the company switchboard on +44 (0)20 7623 8000, or via e-mail return. If you have received this e-mail in error or wish to read our e-mail disclaimer statement and monitoring policy, please refer to http://www.drkw.com/disc/email/ or contact the sender. 3166 ------------------------------------------------------------------------ --------
