Using the encoding NS_URI_SOAP_ENC is fine. If you want to write a custom de/serializer, use BeanSerializer as your guide. You need to feed in the correct header for SOAP to understand.
/lim/ At 03:55 PM 27-01-02, you wrote: >Hi folks, > >Short: > I know how to use a BeanSerializer or sub class of a BeanSerializer to > serialize a customized class. I usually use Constants.NS_URI_SOAP_ENC > when I insert it into SOAPMappingRegistry. > > But I would like to make use of a generic XML Serializer (e.g. > http://www.csse.monash.edu.au/~bren/JSX/) >What encoding style should I use? > > > >Long: > > This is my customized Java class: > > public class PurchaseOrder { > ... > } > > I would like to make use of a generic Java XML Serializer (e.g > http://www.csse.monash.edu.au/~bren/JSX/) as the Serializer and Deserializer. > >public class PurchaseOrderSerializer implements Serializer, Deserializer { > public void marshall(String inScopeEncStyle, Class javaType, Object > src, Object context, Writer sink, NSStack nsStack, XMLJavaMappingRegistry > xjmr, SOAPContext ctx) throws IllegalArgumentException, IOException { > > nsStack.pushScope(); > > SoapEncUtils.generateStructureHeader(inScopeEncStyle, javaType, > context, sink, nsStack, xjmr); > > // Magically obtain a serialized XML string, for example using JSX > String xml = .... > > sink.write(xml); > > nsStack.popScope(); > } > > public Bean unmarshall(String inScopeEncStyle, QName elementType, > Node src, XMLJavaMappingRegistry xjmr, SOAPContext ctx) throws > IllegalArgumentException { > Element root = (Element) src; > PurchaseOrder target; > > // This is sad. > String xml = DOMWriter.nodeToString(src); > > target = (PurchaseOrder).... // Use JSX to get back object > > return new Bean(PurchaseOrder.class, target); >} > >So on the server end, I created this deployment descriptor > ><isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment" > id="urn:myServer"> > <isd:provider type="java" > scope="Application" > methods="SubmitOrder1"> > <isd:java class="xxx.com.Application" static="true"/> > </isd:provider> > > ><isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener> > > <isd:mappings> > <isd:map encodingStyle="http://xxx.com/test" > xmlns:x="urn:wo-xml-demo" qname="x:PurchaseOrder" > javaType="xxx.com.PurchaseOrder" > java2XMLClassName="xxx.com.PurchaseOrderSerializer" > >xml2JavaClassName="xxx.com.PurchaseOrderSerializerOrderSerializer"/> > </isd:mappings> ></isd:service> > > >This is how I execute my call from client > > PurchaseOrderSerializer poSer = new PurchaseOrderSerializer(); > SOAPMappingRegistry smr = new SOAPMappingRegistry(); > String myEnc = "http://xxx.com/test"; > // Map the types. > smr.mapTypes(myEnc, new QName("urn:wo-xml-demo", > "PurchaseOrder"), PurchaseOrder.class, poSer, poSer); > > // Build the call. > call.setSOAPMappingRegistry(smr); > call.setTargetObjectURI("urn:myServer"); > call.setMethodName("SubmitOrder1"); > call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC); > params.addElement(new Parameter("CustomerID", > java.lang.String.class, pin, Constants.NS_URI_SOAP_ENC)); > params.addElement(new Parameter("PurchaseOrder", > PurchaseOrder.class, po, myEnc)); > call.setParams(params); > > // Invoke the call. > try { > resp = call.invoke(serviceURL, ""); > } catch (SOAPException e) { > System.out.print("Caught SOAPException (" + e.getFaultCode() > + "): " + e.getMessage()); > } > > >Problems: > >I always get a SOAPException, something like "Caught SOAPException >(SOAP-ENV:Client): No Serializer found to serialize a >'org.apache.soap.rpc.Parameter' using encoding style 'http://xxx.com/test'. >(Here, I'm kind of surprised that the class is not xxx.com.PurchaseOrder > >If I used Constants.NS_URI_SOAP_ENC, the exception would be > >Caught SOAPException (SOAP-ENV:Client): Parsing error, response was: >The element type "faultstring" must be terminated by the matching end-tag >"</faultstring>". > >I also tried Constants.NS_URI_LITERAL_XML and Constants.NS_URI_XMI_ENC >but no success. > >Help please?