Taras, I have tried your example, but I got compile error. for example, there is no way to find "GCSerializerConstants.TYPE_DELIVERY". What build of AXIS did you use?
Thanks, Emily At 08:34 PM 3/4/2002 -0800, Taras Shkvarchuk wrote: >This may not be the best example, but its something for you to look at. I >have an entry on my todo list to make something better looking, but somehow >things just appear in front of it. > >This is a helloworld type service that takes requests with the body of: > ><helloService xmlns="http://myorg.com/hello"> > <name xsi:type="xsd:string">Taras</name> > <name xsi:type="xsd:string">World</name> ></helloService> > >*************************************** > > > //Process the HTTP Post request > public void doPost(HttpServletRequest request, HttpServletResponse >response) throws ServletException, IOException { > > String contentType=request.getContentType(); > if(contentType==null){ > contentType="text/xml"; > } > String >contentLocation=request.getHeader("Content-Location"); > > AxisClient ac=new AxisClient (); > MessageContext mc=new MessageContext(ac.getClientEngine()); >//******************** > TypeMappingRegistry reg=mc.getTypeMappingRegistry(); > //register your types here > mc.setTypeMappingRegistry(reg); >//******************** > > Message reqMsg=new >Message(request.getInputStream(),false,contentType,contentLocation); > mc.setRequestMessage(reqMsg); > SOAPEnvelope reqEnv=reqMsg.getSOAPEnvelope(); > >//start non axis code > SOAPHeader deliveryHdr= >reqEnv.getHeaderByName(GCSerializerConstants.TYPE_DELIVERY.getNamespaceURI() >, > >GCSerializerConstants.TYPE_DELIVERY.getLocalPart()); > CLDelivery delivery=(CLDelivery) deliveryHdr.getValue(); > //Enjoy your object here >//end non axis code > > ArrayList >children=reqEnv.getBodyByName("http://myorg.com/hello","helloService").getCh >ildren(); > > SOAPEnvelope env=new SOAPEnvelope(); > TypeMapping >tm=(TypeMapping)mc.getTypeMappingRegistry().getTypeMapping(Constants.URI_SOA >P_ENC); > QName stringType=tm.getTypeQName(String.class); > SOAPBodyElement body=new SOAPBodyElement(); > body.setName("helloServiceResponse"); > body.setNamespaceURI("http://myorg.com/hello"); > for(Iterator it=children.iterator();it.hasNext();){ > MessageElement nameNode=(MessageElement) it.next(); > String name=null; > try{ > name=(String)nameNode.getValue(); > }catch(Exception e){ > e.printStackTrace(); > } > MessageElement helloTo=new MessageElement(); > helloTo.setValue("Hello "+name); > helloTo.setType(stringType); > helloTo.setName("helloTo"); > body.addChild(helloTo); > } > env.addBodyElement(body); > >//start non axis code > CLPost post=new CLPost(); > post.setToken(delivery.getToken()); > SOAPHeader postHdr=new SOAPHeader(null,null,post); //excuse >the nulls, my deserializer handles them > env.addHeader(postHdr); >//end non axis code > Message respMsg=new Message(env); > mc.setResponseMessage(respMsg); > >//console polution > respMsg.writeContentToStream(System.out); >//end console polution > > response.setContentType(respMsg.getContentType()); > response.setContentLength(respMsg.getContentLength()); > OutputStream out = response.getOutputStream(); > respMsg.writeContentToStream(out); > out.flush(); > out.close(); > } > > >-----Original Message----- >From: Frank van Lingen [mailto:[EMAIL PROTECTED]] >Sent: Monday, March 04, 2002 6:30 PM >To: [EMAIL PROTECTED] >Cc: [EMAIL PROTECTED] >Subject: axis message example > > >Hi, > >The only example in axis that deals with messages is "proxy". However, this >seems not to be an complete example. Does anybody know (or has) a good stand >alone example that uses messages instead of RPC? > >Frank van Lingen