Hello Scott,
I tried to place DataFeedMessageSerializer.class in %CATALINA_HOME%
\webapps\soap\classes
but it don't run. Same error. I have implemented the Serializer as
follow:
public class DataFeedMessageSerializer
implements Serializer, Deserializer
{
public DataFeedMessageSerializer()
{}
public void marshall(String inScopeEncStyle, Class javaType, Object
src, Object context, Writer sink,
NSStack nsStack, XMLJavaMappingRegistry xjmr,
SOAPContext ctx)
throws IllegalArgumentException, IOException
{
if(!(src instanceof DataFeedMessage)) {
throw new IllegalArgumentException(
"Posso serializzare solo istanze di DataFeedMessage.");
}
try
{
nsStack.pushScope();
if (src != null)
{
SoapEncUtils.generateStructureHeader(inScopeEncStyle,
javaType, context,
sink, nsStack, xjmr);
sink.write(StringUtils.lineSeparator);
ObjOut out=new ObjOut(new PrintWriter(sink));
out.writeObject(src);
ObjOut out2=new ObjOut();
out2.writeObject(src);
sink.write("</" + context + '>');
}
else
{
SoapEncUtils.generateNullStructure(inScopeEncStyle,javaType,
context,
sink, nsStack, xjmr);
}
nsStack.popScope();
}
catch(Exception e)
{
e.printStackTrace();
System.err.println(e.toString());
}
}
public Bean unmarshall(String inScopeEncStyle, QName elementType,
org.w3c.dom.Node src,
XMLJavaMappingRegistry xjmr, SOAPContext ctx)
throws IllegalArgumentException
{
DataFeedMessage oggetto=null;
StringWriter strout=new StringWriter();
PrintWriter writer=new PrintWriter(strout);
try
{
ObjOut serializer=new ObjOut(writer);
Element elem = DOMUtils.getFirstChildElement((Element)src);
System.err.println("***"+src);
serializer.writeObject(elem);
StringReader lettore = new StringReader(writer.toString());
ObjIn in = new ObjIn(lettore);
oggetto= (DataFeedMessage)in.readObject();
}
catch(Exception e)
{
e.printStackTrace();
System.err.println(e.toString());
}
return new Bean(DataFeedMessage.class, oggetto);
}
}
I think I respect the interface of Serializer ... or not?
Stefano Pedon
> Either the class DataFeedMessageSerializer cannot be loaded by Tomcat
or
> it cannot be cast to Serializer. Assuming is does indeed implement t
he
> Serializer interface, you must put the class file in
> %CATALINA_HOME%\webapps\soap\WEB-INF\classes.
>
> Scott Nichol
>
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: "soap-user" <[EMAIL PROTECTED]>
> Sent: Wednesday, October 16, 2002 7:59 AM
> Subject: Help4Problem with custom serializer
>
>
> Hi all, I've a problem with my custom (de)
serializer. I'm using Apache-
> soap2.3.1 & TomCat4.01.
> The client code is:
> ....
> URL url = new URL("http://localhost:8080/soap/servlet/rpcrouter");
>
> Call call = new Call();
>
> SOAPMappingRegistry smr = new SOAPMappingRegistry();
> call.setTargetObjectURI("urn:DataFeedService");
> call.setMethodName("sendMessage");
> call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
> call.setSOAPMappingRegistry(smr);
> DataFeedMessageSerializer msgSer = new DataFeedMessageSerialize
r
> ();
>
> smr.mapTypes(Constants.NS_URI_SOAP_ENC,
> new QName("urn:DataFeedService", "DataFeedMessage"),
> DataFeedMessage.class, msgSer, msgSer);
> DataFeedMessage msg = new DataFeedMessage();
>
> Vector params = new Vector();
> params.addElement(new Parameter("msg",
> DataFeedMessage.class, msg, null));
>
> call.setParams(params);
>
> try {
> Response resp = call.invoke(url, "");
> if(!resp.generatedFault())
> {
> Parameter ret = resp.getReturnValue();
> Object value = ret.getValue();
> System.out.println("*\n"+value);
> }
> else
> {
> Fault fault = resp.getFault();
> System.err.println("--------------------------------");
> System.err.println("Attention: Fault Condition");
> System.err.println("Code: "+ fault.getFaultCode());
> System.err.println("Description: "+
> fault.getFaultString());
> System.err.println("--------------------------------");
>
> }
>
> }
> catch (SOAPException e) {
> System.err.println("Caught SOAPException (" +
> e.getFaultCode() + "): " +
> e.getMessage());
> }
> }
> ....
>
> and the Deployement Descriptor is:
> <isd:service
> xmlns:isd="http://xml.apache.org/xml-soap/deployment"
> id="urn:DataFeedService">
> <isd:provider
> type="java"
> scope="Request"
> methods="sendMessage">
> <isd:java
> class="DataFeedService"
> static="false"/>
> </isd:provider>
>
> <isd:faultListener>org.apache.soap.server.DOMFaultListener
> </isd:faultListener>
> <isd:mappings>
> <isd:map
> encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:x="urn:DataFeedService" qname="x:DataFeedMessage"
> javaType="DataFeedMessage"
> xml2JavaClassName="DataFeedMessageSerializer"
> java2XMLClassName="DataFeedMessageSerializer"
> />
> </isd:mappings>
> </isd:service>
>
> Now, when I run the client, my custom serializer send this:
>
> POST /soap/servlet/rpcrouter HTTP/1.0
> Host: localhost:8080
> Content-Type: text/xml; charset=utf-8
> Content-Length: 524
> SOAPAction: ""
>
> <?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>
> <ns1:sendMessage xmlns:ns1="urn:DataFeedService" SOAP-
> ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
> <msg xsi:type="ns1:DataFeedMessage">
> <?jsx version="1"?>
> <DataFeedMessage alias-ID="0"
> n="0"/>
>
> </msg>
> </ns1:sendMessage>
> </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
>
> and, as you can see, I used JSX in my custom (de)serializer
> and "DataFeedMessage" is a generic
> object (not a Javabean). But the response is:
>
> HTTP/1.1 500 Internal Server Error
> Content-Type: text/xml; charset=utf-8
> Content-Length: 613
> Date: Wed, 16 Oct 2002 12:21:37 GMT
> Server: Java Web Services Developer Pack/1.0-ea1 (HTTP/1.1 Connector)
> Set-Cookie: JSESSIONID=9D5D04EFBB4F2D38FE2F24808B3C22E7;Path=/soap
>
> <?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:Client</faultcode>
> <faultstring>Deployment error in SOAP service
> 'urn:DataFeedService': class name
> 'DataFeedMessageSerializer' could not be resolved as a
> serializer: DataFeedMessageSerializer</faultstring>
> <faultactor>/soap/servlet/rpcrouter</faultactor>
> </SOAP-ENV:Fault>
>
> </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
>
> Maybe I have to change the encoding-style?
> Can you help me?
> Thank you in advance!
>
> Stefano Pedon
>
>
> --
> To unsubscribe, e-mail: <mailto:soap-user-
[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:soap-user-
[EMAIL PROTECTED]>
>
>
>
>
> --
> To unsubscribe, e-mail: <mailto:soap-user-
[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:soap-user-
[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>