| ï
Have you thought of ways to insert the
XML message directly into the SOAP body without parsing XML?
Is that what is shown in the code?
It seems that if parsing the message is required
before the insertion can be done, it is really inefficient.
it has an XML processing (open sourced) that allows
you to stick a message directly into the other one.
Let me know if you have any questions.
----- Original Message -----
Sent: Sunday, August 01, 2004 1:58
PM
Subject: Re: Going from Text Based XML to
a SOAPBody?
I've made some great progress on
this. I now have almost what I am looking for. I have the following code in my
invoke method:
public void invoke(MessageContext msgContext) throws
AxisFault { System.out.println("In INVOKE!!!!!!!!");
Message resMsg
= msgContext.getResponseMessage(); SOAPEnvelope resEnv; // If we didn't
have a response message, make sure we set one up // with the appropriate
versions of SOAP and Schema if (resMsg == null) { resEnv = new
SOAPEnvelope(msgContext.getSOAPConstants(),
msgContext .getSchemaVersion());
resMsg = new
Message(resEnv); msgContext.setResponseMessage(resMsg); } else
{ resEnv = resMsg.getSOAPEnvelope(); }
Message reqMsg =
msgContext.getRequestMessage(); SOAPEnvelope reqEnv =
reqMsg.getSOAPEnvelope();
DocumentBuilderFactory domFactory =
DocumentBuilderFactory .newInstance(); DocumentBuilder domBuilder =
null; Document doc = null; try { domBuilder =
domFactory.newDocumentBuilder();
doc =
domBuilder.parse("/Users/mlb/test.xml");
} catch (Exception e)
{ e.printStackTrace();
}
RPCElement body = null; body =
new RPCElement("rpc-resp");
RPCElement resBody = new
RPCElement("Response"); resBody.setPrefix(body.getPrefix()); resBody.setNamespaceURI(body.getNamespaceURI()); try
{ resBody.setEncodingStyle(msgContext.getEncodingStyle()); RPCParam
param = new RPCParam(new QName("http://soapinterop.org/", "echoString"),
doc); resBody.addParam(param); resEnv.addBodyElement(resBody); }
catch (SOAPException e1) { // TODO Auto-generated catch
block e1.printStackTrace(); }
}
I took most of the code
from the JavaProdiver and the RPCProvider. This will produce the following
SOAP message: <?xml version="1.0"
encoding="UTF-8"?> <soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body> <echoString
xmlns="http://soapinterop.org/"> <myxml xmlns="">
<val>test</val> <val>test</val>
<val>test</val> </myxml> </echoString>
</soapenv:Body> </soapenv:Envelope>
Everything is
great except for the "<echoString" tag. The tag is generated be the
RPCParam which deserizlized the Document object. It looks like that at this
point I need to look at the RPCParam class to see if I can create a version
that will not create the wrapper tags and will just de-serialize the Document
into the soap body. Any
thoughts?
-------------------------------------------------------------------------------------------------- Marc
Boorshtein Sr. Software Engineer, Octet
String [EMAIL PROTECTED] On Aug 1, 2004, at 1:36 PM, Vijai
Mohan wrote:
I
think that will work./x-tad-bigger>/color>/fontfamily>
/x-tad-bigger>/color>/fontfamily>
/x-tad-bigger>/color>/fontfamily>
Vijai
Mohan/x-tad-bigger>/bigger>/color>/fontfamily>
Software
Design Engineer/x-tad-bigger>/bigger>/color>/fontfamily>
SensorLogic/x-tad-bigger>/bigger>/color>/fontfamily>Â/x-tad-bigger>/bigger>/color>/fontfamily>M/x-tad-bigger>/bigger>/bigger>/bigger>/color>2/x-tad-bigger>/bigger>/color>M/x-tad-bigger>/bigger>/bigger>/bigger>/color>/fontfamily>
/x-tad-bigger>made
easy./x-tad-bigger>/fontfamily>/bigger>/color>
972-934-7375
x 2111/x-tad-bigger>/bigger>/color>/fontfamily>
972-934-7376
(fax)/x-tad-bigger>/bigger>/color>/fontfamily>
[EMAIL PROTECTED]/x-tad-bigger>/bigger>/color>/fontfamily>
www.Sensorlogic.com/x-tad-bigger>/bigger>/color>/fontfamily>
/bigger>/bigger>/color>/fontfamily><image.tiff>
/x-tad-bigger>/color>/fontfamily>
-----Original
Message-----/x-tad-bigger>/fontfamily> From:/x-tad-bigger>/fontfamily>
Marc Boorshtein [mailto:[EMAIL PROTECTED]/x-tad-bigger>/fontfamily> /x-tad-bigger>Sent:/x-tad-bigger>
Sunday, August 01, 2004 1:33 PM/x-tad-bigger>/fontfamily> To:/x-tad-bigger>/fontfamily>
[EMAIL PROTECTED]/x-tad-bigger>/fontfamily> Subject:/x-tad-bigger>/fontfamily>
Re: Going from Text Based XML to a
SOAPBody?/x-tad-bigger>/fontfamily>
/bigger>/bigger>/fontfamily>
Thanks
for the tip, but this is a bit simple for what I'm looking to do. I'd like
to build a provider that will let me take the XML in the request's body,
perform some tasks to extract the information into an object model and then
pass that information into a dynamic content generation system to generate
some XML and add it to the SOAPBody. From the looks of it, I can serialize
the XML into Document as you showed below, and then create an RPCElement and
add it to the body as it's done in RPCProvider. Is this correct?/bigger>/bigger>/fontfamily>
--------------------------------------------------------------------------------------------------/bigger>/bigger>/fontfamily> Marc
Boorshtein/bigger>/bigger>/fontfamily> Sr.
Software Engineer, Octet String/bigger>/bigger>/fontfamily> [EMAIL PROTECTED]/bigger>/bigger>/fontfamily> On
Aug 1, 2004, at 12:41 PM, Vijai Mohan wrote:/bigger>/bigger>/fontfamily>
Create
a simple webservice and use this snippet to return a xml document/bigger>/bigger>/fontfamily> from
an xml file./bigger>/bigger>/fontfamily> Axis
automatically converts the Document in to the soap body ./bigger>/bigger>/fontfamily>
public
static Document getXMLDocument(){/bigger>/bigger>/fontfamily> DocumentBuilderFactory
domFactory = DocumentBuilderFactory/bigger>/bigger>/fontfamily> .newInstance();/bigger>/bigger>/fontfamily> DocumentBuilder
domBuilder = null;/bigger>/bigger>/fontfamily> try
{/bigger>/bigger>/fontfamily> domBuilder
= domFactory.newDocumentBuilder();/bigger>/bigger>/fontfamily>
Document
doc =
domBuilder.parse("c:\\XMLFILE.xml");/bigger>/bigger>/fontfamily>
return
doc;/bigger>/bigger>/fontfamily> }
catch (Exception e) {/bigger>/bigger>/fontfamily> e.printStackTrace();/bigger>/bigger>/fontfamily> return
null;/bigger>/bigger>/fontfamily> }/bigger>/bigger>/fontfamily> }/bigger>/bigger>/fontfamily>
Vijai
Mohan/bigger>/bigger>/fontfamily> Software
Design Engineer/bigger>/bigger>/fontfamily> SensorLogic/bigger>/bigger>/fontfamily>Â/bigger>/bigger>/fontfamily>M2M
made easy./bigger>/bigger>/fontfamily> 972-934-7375
x 2111/bigger>/bigger>/fontfamily> 972-934-7376
(fax)/bigger>/bigger>/fontfamily> [EMAIL PROTECTED]/bigger>/bigger>/fontfamily> www.Sensorlogic.com/bigger>/bigger>/fontfamily>
-----Original
Message-----/bigger>/bigger>/fontfamily> From:
Marc Boorshtein [mailto:[EMAIL PROTECTED]/bigger>/bigger>/fontfamily> Sent:
Sunday, August 01, 2004 12:11 PM/bigger>/bigger>/fontfamily> To:
[EMAIL PROTECTED]; [EMAIL PROTECTED]/bigger>/bigger>/fontfamily> Subject:
Going from Text Based XML to a
SOAPBody?/bigger>/bigger>/fontfamily>
Hello,/bigger>/bigger>/fontfamily>
I
am working on implementing a document service in which I want to take/bigger>/bigger>/fontfamily> text
representation of XML and add it to a SOAPBody. From the looks of /bigger>/bigger>/fontfamily> it,
it appears that I have to use an XML Parser to go from/bigger>/bigger>/fontfamily> XML->SOAPElement
in a similar way that I would parse XML into a DOM/bigger>/bigger>/fontfamily> Tree.
The only problem is that I can't find this "parsing" class. I /bigger>/bigger>/fontfamily> found
SOAPFactory, but it doesn't seem to be a parser. Am I missing/bigger>/bigger>/fontfamily> something?/bigger>/bigger>/fontfamily>
Thanks!/bigger>/bigger>/fontfamily>
------------------------------------------------------------------------/bigger>/bigger>/fontfamily> --------------------------/bigger>/bigger>/fontfamily> Marc
Boorshtein/bigger>/bigger>/fontfamily> Sr.
Software Engineer, Octet String/bigger>/bigger>/fontfamily> [EMAIL PROTECTED]/bigger>/bigger>/fontfamily>
|