HI folks, I defined a Java Bean, called FamilyData:
The important snippet is below, showing the four class members: public class FamilyData { ... protected int familyId; protected String description; protected int [] memberIds; protected String [] memberUsernames; ... } I do have getter and setter methods to make the class a proper Java Bean... full file is attached instead of included inline to make reading this email easier. I've also attached the Java client code that's making the call. Here is my WSDD file: <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <service name="disFamilyManagement" provider="java:RPC"> <namespace>http://family.dis.disney</namespace> <parameter name="className" value="disney.dis.family.FamilyManager"/> <parameter name="allowedMethods" value="*"/> <parameter name="scope" value="application"/> <beanMapping qname="ns:DISResult" xmlns:ns="http://dis.disney" languageSpecificType="java:disney.dis.DISResult"/> <beanMapping qname="ns:FamilyData" xmlns:ns="http://family.dis.disney" languageSpecificType="java:disney.dis.family.FamilyData"/> </service> </deployment> I want to pass an instance as the return type of a web service end point call. I'm guessing the problem has to do with serialization/deserialization but not sure. Here is the exception I'm getting: ; nested exception is: org.xml.sax.SAXParseException: Premature end of file. AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: org.xml.sax.SAXParseException: Premature end of file. faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException: Premature end of file. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:215) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:386) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316) at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:230) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:798) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242) at javax.xml.parsers.SAXParser.parse(SAXParser.java:375) at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:226) at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:645) at org.apache.axis.Message.getSOAPEnvelope(Message.java:424) at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:173) at org.apache.axis.client.Call.invokeEngine(Call.java:2719) at org.apache.axis.client.Call.invoke(Call.java:2702) at org.apache.axis.client.Call.invoke(Call.java:2378) at org.apache.axis.client.Call.invoke(Call.java:2301) at org.apache.axis.client.Call.invoke(Call.java:1758) My question is: do I have to set a serializer and deserializer on the call object? How do I do that? I already have a BeanSerializerFactory and BeanDeserializerFactory set on the call. 1. Can I set several serializers on the same call - the BeanSerializerFactory and BeanDeserializerFactory - ArraySerializer and ArrayDeserializer 2. What are the arguments in the ArraySerializer class? public ArraySerializer(java.lang.Class javaType, QName xmlType, QName componentType) - What's the class for an array? - What's the second arg -- something like: new QName("http://family.dis.disney", "array"); - What's the component QName (third arg)? 3. Is there an array deserializer? 4. Am I completely off-base? Many thanks, Vartan __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
package disney.dis.family; /** * Represents a family structure that exists in the DIS database. * Defines a proper Java Bean so that instances can be passed in web * services calls. * * @author Vartan Piroumian */ public class FamilyData { /** * No-arg constructor. */ public FamilyData() { super(); } /** * Gets this object's family ID. * * @return the ID representing this family. */ public int getFamilyId() { return familyId; } /** * Sets this objects family ID to the specified value. * * @param id the family ID representing this family. */ public void setFamilyId(int id) { familyId = id; } /** * Gets the description text for this instance. * * @return the family description text, originally retrieved from * the "families" DIS database table. */ public String getDescription() { return description; } /** * Sets the description text for this instance. * * @param desc the family description text, originally retrieved from * the "families" DIS database table. */ public void setDescription(String desc) { description = desc; } /** * Returns a collection of user IDs representing all members of this * family. * * @return a collection of user IDs for all members of this family. */ public int [] getMemberIds() { return memberIds; } /** * Sets the set of all family members. * * @param allMembers a collection of the user IDs of all family * members. */ public void setMemberIds(int [] allMembers) { memberIds = allMembers; } /** * Returns a collection of user names representing all members of * this family. * * @return a collection of user IDs for all members of this family. */ public String [] getMemberUsernames() { return memberUsernames; } /** * Sets the set of all family members. * * @param allMembers a collection of the user names of all family * members. */ public void setMemberUsernames(String [] allMembers) { memberUsernames = allMembers; } /** * The unique family ID. */ protected int familyId; /** * The text that describes this family, entered when the family * definition was created. */ protected String description; /** * The user IDs of all the members of this family. */ protected int [] memberIds; /** * The usernames of all family members. */ protected String [] memberUsernames; }
public FamilyData getFamilyData(int familyId) { FamilyData familyData = null; try { ServiceFactory serviceFactory = ServiceFactory.newInstance(); URL wsdlDocLoc = new URL(familyEndpoint); QName portName = new QName(familyEndpoint); QName localPart = new QName("getFamily"); QName opQName = new QName("getFamily"); Service service = serviceFactory.createService(localPart); Call call = (Call) service.createCall(portName); call.addParameter("familyId", new QName("int"), ParameterMode.IN); call.setTargetEndpointAddress(wsdlDocLoc); call.setOperationName(opQName); Class cl = FamilyData.class; QName classQName = new QName("http://family.dis.disney", "FamilyData"); BeanSerializerFactory bsf = new BeanSerializerFactory(cl, classQName); BeanDeserializerFactory bdf = new BeanDeserializerFactory(cl, classQName); call.registerTypeMapping(cl, classQName, bsf, bdf); // Class arrayClass = [].class; // QName arrayQName = new QName("http://family.dis.disney", // "Array"); // ArraySerializer aSer = // new ArraySerializer(cl, arrayQName, call.setReturnType(new QName("FamilyData")); Object [] args = {familyId}; familyData = (FamilyData) call.invoke(args); if (familyData == null) { System.out.println("No object returned."); return null; } System.out.println("Printing data from FamilyData return object..."); System.out.println("family ID = " + familyData.getFamilyId()); System.out.println("description = " + familyData.getDescription()); System.out.print("member IDs = "); int [] ids = familyData.getMemberIds(); int i = 0; do { System.out.print(ids[i] + ", "); } while (i < ids.length); System.out.println(); i = 0; String [] names = familyData.getMemberUsernames(); do { System.out.print(names[i] + ", "); } while (i < names.length); System.out.println(); System.out.println("Done."); } catch (Exception ex) { System.out.println(ex.getMessage()); ex.printStackTrace(); } return familyData; }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]