You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@xml.apache.org by Denis Haskin <dw...@earthlink.net> on 2001/02/16 21:56:43 UTC

How to create and send a SOAP Envelope manually?

Perhaps this is not the way to go about this, but for semantic reasons I
would like to have my code create the SOAP Envelope and send it to a
server.

In other words, I don't want to use an org.apache.soap.rpc.Call.

First, is there any reason this is nuts?

Second, what am I missing?  I can create the Envelope just fine, but
when I try to do anything that marshalls the Envelope in preparation for
sending its serialized form (e.g. marshall, or Message.send, or
SOAPHTTPConnection.send), it throws an exception about 'Unknown type of
body entry'.

For the example, the code fragment below throws:
java.lang.IllegalArgumentException: Unknown type of body entry: 'class
org.apache.soap.rpc.Parameter'.

Anyone have any suggestions, comments?

Thanks,

dwh

--- cut here ---

Envelope env = new Envelope();
Body body = new Body();
Vector bodyEntries = new Vector();
bodyEntries.addElement(new Parameter("paramName", String.class, "This is
a test", null));
body.setBodyEntries(bodyEntries);
env.setBody(body);

SOAPMappingRegistry smr = new SOAPMappingRegistry();
SOAPContext reqCtx = new SOAPContext();
StringWriter payloadSW = new StringWriter();
try {
    env.marshall(payloadSW, smr, reqCtx);
...etc...