Hi, Have you looked at Sun's JAXM specification? Basically, it's a standardised SOAP API for Java.
We're currently developing an implementation of the JAXM Version 1.0 specification which should be available soon. We allow SOAP messages to be transported over HTTP or JMS. JAXM uses MessageFactory objects to produce SOAPMessage instances, which you then populate with your message content. If you're sending via HTTP, you'll generally use a SOAPConnection object to do this. Anyway, here's an example of how you could use JAXM to produce the same message and send to an endpoint via HTTP:- ---------- SOAPConnectionFactory connectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = connectionFactory.createConnection(); MessageFactory factory = MessageFactory.newInstance(); SOAPMessage message = factory.createMessage(); SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPBody body = envelope.getBody(); Name name = envelope.createName("methodToCall", "ns1", "uri:MySoapObjectToCall"); SOAPBodyElement element = body.addBodyElement(name); URLEndpoint endpoint = new URLEndpoint(some_url); SOAPMessage reply = connection.call(message, endpoint); ------------- Obviously, you will only receive a reply from the connection.send() call if one is actually sent back! What is also quite nice is that it's very easy to create SOAPMessage instances from an XML file. All you need to do is create an InputStream containing the file content, and set the "Content-Type" MIME header for the message (you can also set other MIME headers if you wish). So, the code would be:- ------------- SOAPConnectionFactory connectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = connectionFactory.createConnection(); MessageFactory factory = MessageFactory.newInstance(); FileInputStream inputStream = new FileInputStream(new File("some_xml_file.xml")); MimeHeaders headers = new MimeHeaders(); headers.addHeader("Content-Type", "text/xml"); SOAPMessage message = factory.createMessage(headers, inputStream); SOAPMessage reply = connection.call(message, new URLEndpoint("some_url")); ------------- Really easy! Feel free to mail me at [EMAIL PROTECTED] for more information on our JAXM implementation. Alternatively, our website is http://www.prismtechnologies.com Thanks, Iain Ted Poole wrote: > >-----Original Message----- >From: Beer, Christian [mailto:[EMAIL PROTECTED]] >Sent: 08 March 2002 10:27 >To: '[EMAIL PROTECTED]' >Subject: AW: soap messaging XML ??? > > >Try it this way: > >------- >DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); >DocumentBuilder db = dbf.newDocumentBuilder(); >Document doc = db.newDocument(); >Element methodCall = doc.createElement("ns1:methodToCall"); >methodCall.setAttribute("xmlns:ns1", "uri:MySoapObjectToCall); >methodCall.appendChild(message_body_element); > >Body body = new Body(); >Vector bodyEntries = new Vector(); >bodyEntries.add(methodCall); >body.setBodyEntries(bodyEntries); > >Envelope msgEnvelope = new Envelope(); >msgEnvelope.setBody(body); > >Message msg = new Message(); > >msg.send(endpoint, "", msgEnvelope); >------- > >Christian > >-----Ursprüngliche Nachricht----- >Von: Shashi Anand [mailto:[EMAIL PROTECTED]] >Gesendet: Freitag, 8. März 2002 11:14 >An: [EMAIL PROTECTED]; [EMAIL PROTECTED]; >[EMAIL PROTECTED] >Betreff: soap messaging XML ??? > > >Hi, > >One strange thing I noticed is that all the tutorials explaining the SOAP >messaging assume whole SOAP message to be readilly available in XML file, >where as this is not the case. None of tutorials explain how to form this >SOAP message given the XML which is only part of message body. >Does somebody have any idea on how to form the SOAP message using API. > >+Shashi Anand >(Senior Software Engineer >8Infogain India >OB 15 Sec 58, NOida, UP 201301, India > > > -- Iain Potter Senior Software Engineer PrismTech Limited www.prismtechnologies.com