Todd,
You basically figured this out yourself:
>>>>
Another question: the only reference to the class GuideSerializer that is
made is at the client while building the call. Is this correct? Do I need
to somehow map GuideSerializer to the type Guide in the
DeploymentDescriptor???
<<<<
If, as your original message claims, Guide implements the Serializer and
Deserializer interfaces, it must be listed as the [de-]serializing class in your
deployement descriptor, as in
<isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:x="urn:tickler-guide" qname="x:guide"
javaType="com.salarinc.tickler.foundation.Guide"
java2XMLClassName="com.salarinc.tickler.foundation.Guide"
xml2JavaClassName="com.salarinc.tickler.foundation.Guide"/>
It looks, however, like you have a separate class for [de-]serialization,
GuideSerializer. In that case, use
<isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:x="urn:tickler-guide" qname="x:guide"
javaType="com.salarinc.tickler.foundation.Guide"
java2XMLClassName="com.salarinc.tickler.foundation.GuideSerializer"
xml2JavaClassName="com.salarinc.tickler.foundation.GuideSerializer"/>
Scott Nichol
----- Original Message -----
From: "Todd D. Johnson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 10, 2002 1:30 PM
Subject: Problems with (De)Serializers w/ Code
> I have attached code samples to the bottom. I am resending bc I did not see
> my earlier message show up on the archives. I am using the following
> environment
> java 1.4
> Tomcat 4.0.3
> Soap 2.3
> Xerces 1.4.4
>
> I have written a simple class that implements not only the class functions,
> but the serialization and deserialization as well. I am having problems
> calling a simple function on the class that returns itself. Right now the
> class has only one member (a string) and thus the marshall and unmarshall
> functions are responsible for handling just that member. When a client
> calls the function, apache tomcat loads the constructor, calls the function,
> but never calls the marshall function (as reported through the apache
> console). The only thing returned to the client is
>
> Fault Code = SOAP-ENV:Server
> Fault String = java.lang.NullPointerException
>
> Does anyone have any ideas? I've gotten the simple soap examples to run
> just fine. (And subsequently my code and descriptor are pretty identical)
>
> It's pretty weird because I know that the marshall/unmarshall methods are
> never being accessed by the server. The exception is being thrown at
> (RPCJavaProvider.java:138) which seems to me that it can't find a reference
> to my (de)serializer.
>
> Another question: the only reference to the class GuideSerializer that is
> made is at the client while building the call. Is this correct? Do I need
> to somehow map GuideSerializer to the type Guide in the
> DeploymentDescriptor???
>
> Thanks,
>
> Todd D. Johnson
>
> Implementing server class:
>
> public Guide getSampleGuide(int guideSeq){
> System.out.println("Guide.getSampleGuide called");
> setGuideName("Sample Tickler Guide");
> //g.setGuideType("DefaultGuidePublishingAgentImpl");
> System.out.println("Guide.getSampleGuide exiting");
> return this;
> }
>
> DeploymentDescriptor:
>
> <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
> id="urn:tickler">
> <isd:provider type="java" scope="Request" methods="getSampleGuide">
> <isd:java class="com.salarinc.tickler.foundation.Guide"
> static="false"/>
> </isd:provider>
>
> <isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListene
> r>
> <isd:mappings>
> <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:x="urn:tickler-guide" qname="x:guide"
> javaType="com.salarinc.tickler.foundation.Guide"
>
> java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer"
>
> xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/>
> </isd:mappings>
> </isd:service>
>
> Client code:
>
> Integer x=new Integer(7);
> Integer y=new Integer(8);
> final String urn= "urn:tickler";
>
> Vector params = new Vector();
>
> URL url = null;
> try{
> url = new URL("http://" + serverhost + ":" + serverport+
> soapservlet);
> }catch(java.net.MalformedURLException e){
> System.out.println("Error creating a url: "+e.getMessage());
> }
>
> ServiceManagerClient client = new ServiceManagerClient(url);
> try{
> String[] apps = client.list();
> System.out.println("Deployed Services at "+url.toString()+"
> are:");
> for(int i = 0; i < apps.length; i++){
> System.out.println("\t"+apps[i]);
> DeploymentDescriptor desc = client.query(apps[i]);
> System.out.println("\t\tMethods for
> "+desc.getScriptFilenameOrString()+" are:");
> String[] methods = desc.getMethods();
> for(int j = 0; j < methods.length; j++){
> System.out.println("\t\t\t"+methods[j]);
> }
> }
> }catch(SOAPException e){
> System.out.println("Could not connect to ServiceManager at
> "+url.toString()+": "+e.getMessage());
> }
>
> // Build the call.
> Call call = new Call();
> SOAPHTTPConnection shc = new SOAPHTTPConnection ();
> shc.setMaintainSession (true);
> call.setSOAPTransport(shc);
> call.setTargetObjectURI(urn);
>
> call.setEncodingStyleURI("http://schemas.xmlsoap.org/soap/encoding/");
>
> call.setMethodName("getSampleGuide");
>
> params.addElement(new Parameter("guideSeq" , Integer.class, new
> Integer(7), null));
>
> call.setParams(params);
> GuideSerializer ser_0 = new GuideSerializer();
> SOAPMappingRegistry smr = call.getSOAPMappingRegistry();
> smr.mapTypes("http://schemas.xmlsoap.org/soap/encoding/", new QName(
> "urn:tickler-guide", "guide"), Guide.class, ser_0, ser_0);
> call.setSOAPMappingRegistry(smr);
> Response resp = null;
> try{
> resp = call.invoke(url,"");
> }catch(org.apache.soap.SOAPException e){
> System.out.println("Got a soap exception while invoking
> "+e.getMessage());
> System.exit(1);
> }
>
> if (resp.generatedFault()) {
> Fault fault = resp.getFault();
> System.out.println("Ouch, the call failed: ");
> System.out.println(" Fault Code = " + fault.getFaultCode());
> System.out.println(" Fault String = " +
> fault.getFaultString());
> } else {
> Parameter result = resp.getReturnValue();
> if(result.getType() == Guide.class){
> Guide g = (Guide)result.getValue();
> System.out.println("The guide name is " + g.getGuideName());
> }else{
> System.out.println("ERROR server returned a
> :"+result.getType().toString());
> System.exit(1);
> }
>
> }
>
> Serializer/Deserializer
>
> public Bean unmarshall(String inScopeEncStyle, QName elementType,
> Node src, XMLJavaMappingRegistry xjmr, SOAPContext ctx)
> throws IllegalArgumentException
> {
> Element root = (Element)src;
> Element tempEl = DOMUtils.getFirstChildElement(root);
> Guide target;
>
> try
> {
> target =
> (Guide)Guide.class.newInstance
> ();
> }
> catch (Exception e)
> {
> throw new IllegalArgumentException("Problem instantiating bean: "
> + e.getMessage());
> }
>
> while (tempEl != null)
> {
> Bean paramBean = xjmr.unmarshall(inScopeEncStyle,
> RPCConstants.Q_ELEM_PARAMETER,
> tempEl, ctx);
> Parameter param = (Parameter)paramBean.value;
> String tagName = tempEl.getTagName();
>
>
> if (tagName.equals("name"))
> {
> target.setGuideName((java.lang.String)param.getValue());
> }
>
> tempEl = DOMUtils.getNextSiblingElement(tempEl);
> }
>
> return new Bean(Guide.class, target);
> }
>
> 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);
>
> sink.write(StringUtils.lineSeparator);
>
> Guide src2 = (Guide)src;
> Parameter param;
>
> param = new Parameter("namme", String.class, new String
> ("Test"), null);
> xjmr.marshall(inScopeEncStyle, Parameter.class, param, null,
> sink, nsStack, ctx);
> sink.write(StringUtils.lineSeparator);
>
> sink.write("</" + context + '>');
>
> nsStack.popScope();
> }
>
>
>
>
> server gunk:
> </SHTTP/1.1 500 Internal Server Error Content-Type: text/xml; charset=utf-8
> Content-Length: 3369 Date: Mon, 10 Jun 2002 14:24:09 GMT Server: Apache
> Tomcat/4.0.2 (HTTP/1.1 Connector) Set-Cookie:
> JSESSIONID=4F9E94EB66517ADC4DEAD0E2AE6E5966;Pa<?xml version='1.0'
> encoding='UTF-8'?> <SOAP-ENV:Envelope
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body>
> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Server</faultcode>
> <faultstring>java.lang.NullPointerException</faultstring>
> <faultactor>/soap/servlet/rpcrouter</faultactor> <detail>
> <stackTrace>[SOAPException: faultCode=SOAP-ENV:Server;
> msg=java.lang.NullPointerException] at
> org.apache.soap.providers.RPCJavaProvider.invoke(RPCJavaProvider.java:138)
> at
> org.apache.soap.server.http.RPCRouterServlet.doPost(RPCRouterServlet.java:35
> 4) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
> FilterChain.java:247) at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicat
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
> va:243) at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66) at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
> va:190) at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66) at
> org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:2
> 46) at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 64) at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at
> org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
> ) at org.ndardPipeline.invokeNext(StandardPipeline.java:566) at
> org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
> java:170) at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 64) at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170
> ) at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 64) at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 64) at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
> :174) at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66) at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.CainerBase.java:943) at
> org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
> 1012) at
> org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107
> ) at java.lang.Thread.run(Thread.java:536) </stackTrace> </detail>
> </SOAP-ENV:Fault>
>
>
>