You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Erik Norgaard <no...@locolomo.org> on 2006/09/27 16:10:52 UTC

Building Message client with axis (1.4)

Hi:

I am trying to build a Message style client with Axis 1.4, so far I am 
not sending anything to the service, just printing out to see what I get.

This is my code:

   Message reqMsg = new Message(new SOAPEnvelope());
   try {
	SOAPEnvelope reqSoap = reqMsg.getSOAPEnvelope();
	reqSoap.setMessageType("REQUEST");
	reqSoap.addHeader();
   } catch (Exception e) { }

   try {
	System.out.println(reqMsg.getSOAPPartAsString());
   } catch (Exception e) { }

And this is the output I get:

<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/></soapenv:Envelope>

Now:

1) How do I control the namespace prefixes? It seems that the 
constructor made up some standard ones that I may need later.

2) What happened to the header? The addHeader() should construct an 
empty header element like the existing body element.

3) There is no xml declaration, <?xml version="1.0" encoding="UTF-8"?>, 
how do I add that?

4) Is there any neat way to pretty print the output? I got all in one 
long line, pretty inconvenient.

Finally:

I'm a bit confused as to how to construct the request: Do I need first 
to create a message context? or is this implicitly created with the 
message? or do I need to add the message to some message context later? 
and what is this message context anyway?

Also it seems that one should construct separate MessageElements and 
then attach these as children to other elements rather than create a 
child element and manipulate it. This leaf to root approach seem quite 
counter intuitive - what about namespaces will the serialization clear 
it up so that each namespace only occurs once?

Any samples on how to implement a Message style client/service?

Thanks, Erik
-- 
Ph: +34.666334818                      web: http://www.locolomo.org
X.509 Certificate: http://www.locolomo.org/crt/8D03551FFCE04F0C.crt
Key ID: 69:79:B8:2C:E3:8F:E7:BE:5D:C3:C3:B1:74:62:B8:3F:9F:1F:69:B9

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org