communication between java and other programs
Hi, I've got a Java progrom written. Now I want that my program is abel to react on actions happens in another program (p.e. c++, c#). That program isn't written up to know. It have to be also possible that the c++/c#-program react on actions in my Java program. In a Forum i've red that will be possible with axis. Is that right? Better using axis2 or axis1.x? Is there anywhere a tutorial how to do something like that? Please excuse my bad english. Best Regards Christian -- Analog-/ISDN-Nutzer sparen mit GMX SmartSurfer bis zu 70%! Kostenlos downloaden: http://www.gmx.net/de/go/smartsurfer
Generating Web Service with Axis 1.3
Hi all,Using the option -s and -S true with WSDL2Java tool, it creates the server-side and Skeleton classes. A XXXImpl class is created and I always have to modify it to add code to delegate the calls to my original business class. I have not tested yet, but as I can see, if I omit -S true (skeleton), Axis call directly the XXXImpl class. Is that right? What is the difference between this option and the skeleton option?Axis code generation process seems to be a little bit cumbersome, because, first of all, I have to create the WSDL, then the server-side classes are generated from the WSDL. It would be much easier if we could do it with only one single step and it could also use my original business class instead of make me add code to delegate the calls from the XXXImpl class to the business class. Another point, when my method returns a custom type (i.e.: ProductInfo), it creates a new similiar class (same name), just to add some code related to SOAP into it. But if this ProductInfo class is not in the same directory as my business class is, Axis overwrites it. Why is that? Axis is cool, but sometimes are confusing or make me work more. I´d expect this kind of tool do the whole code generation, ready to be deployed, the same way Oracle JDeveloper works.ThanksDaniel
Re: [Axis2-0.94] service deploy fails when ports bound to SOAP 1.2 in WSDL
This has been fixed in latest SVN :) -- dims On 4/5/06, Andreas Bobek [EMAIL PROTECTED] wrote: Both, code generation and deploying of WSDL 1.1 / SOAP 1.2 services is now working in 0.95 :-) BUT, if I use AxisService.printWSDL(OutputStream out, String requestIP) I get a WSDL with SOAP 1.1 binding! Furthermore, if there is no SOAP 1.1 namespace declared in the original WSDL file, I get an exception WSDLException: faultCode=OTHER_ERROR: Can't find prefix for 'http://schemas.xmlsoap.org/wsdl/soap/'. Namespace prefixes must be set on the Definition object using the addNamespace(...) method.: at org.apache.axis2.description.AxisService.printUsingWSDLDefinition(AxisServic e.java:497) at org.apache.axis2.description.AxisService.printWSDL(AxisService.java:427) ... I suppose this a limitation of WSDL4J ? Just for info, Andreas Bobek. -Ursprüngliche Nachricht- Von: Deepal Jayasinghe [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 28. März 2006 06:16 An: axis-user@ws.apache.org Betreff: Re: [Axis2-0.94] service deploy fails when ports bound to SOAP 1.2 in WSDL oh I didnt know that :( Davanum Srinivas wrote: Deepal, Already fixed :) see http://tinyurl.com/jy8mz fix should be in 0.95. -- dims On 3/26/06, Deepal Jayasinghe [EMAIL PROTECTED] wrote: yes , thats a bug in Axis2 and we will fix that before 1.0. Andreas Bobek wrote: Hi, I have a WSDL file with a binding to SOAP 1.2 only, e.g. I use xmlns:soap12=http://schemas.xmlsoap.org/wsdl/soap12/; instead of xmlns:soap11=http://schemas.xmlsoap.org/wsdl/soap/; Code generation works well. Deploying with bindings to SOAP 1.1 works well, too. But when bind to SOAP 1.2 I get follow exception: org.apache.wsdl.impl.WSDLProcessingException: no port with soap binding found at org.apache.axis2.deployment.AxisServiceBuilder.getAxisServi ce(AxisSer viceBui lder.java:219) at org.apache.axis2.deployment.AxisServiceBuilder.getAxisServi ce(AxisSer viceBui lder.java:127) at org.apache.axis2.deployment.repository.util.ArchiveReader.p rocessWSDL File(Ar chiveReader.java:267) at org.apache.axis2.deployment.repository.util.ArchiveReader.p rocessWSDL s(Archi veReader.java:333) at org.apache.axis2.deployment.DeploymentEngine.doDeploy(Deplo ymentEngine.java: 383) .. which I think means WSDL-SOAP 1.2 is not known. Debugging inside AxisServiceBuilder: javax.wsdl.extensions.UnknownExtensibilityElement UnknownExtensibilityElement ({http://schemas.xmlsoap.org/wsdl/soap12/}binding) Is this a limitation in Axis up to now? Thank you, Andreas Bobek. -- Thanks, Deepal ~Future is Open~ -- Davanum Srinivas : http://wso2.com/blogs/ -- Thanks, Deepal ... ~Future is Open~ -- Davanum Srinivas : http://wso2.com/blogs/
wsrf webservice client
Hi, I'm trying to create a WSRF webservice client, and since AXIS2 supports ws-addressing it might be a good choice. Does anyone have experience creating WSRF webservices client using AXIS2? Asaf Lahav VP RD, Prima Grid LTD. Cellular: 972-54-4717955 Phone: 972-3-6540255 Fax: 972-3-6540254
Re: Generating Web Service with Axis 1.3
Daniel Destro wrote: Axis code generation process seems to be a little bit cumbersome, because, first of all, I have to create the WSDL, then the server-side classes are generated from the WSDL. It would be much easier if we could do it with only one single step and it could also use my original business class instead of make me add code to delegate the calls from the XXXImpl class to the business class. If you already have both the WSDL and the implementation classes, then you don't need to use WSDL2Java at all. Instead, you would just write a WSDD file pointing to your existing WSDL and Java code. You would need to include type mappings in that file, potentially using bean serializers or even custom serializers if your data classes are not beans. This will not be a trivial process, since you need to match your existing code to the existing WSDL interface, and there may be problems on either side. WSDL2Java is meant to generate Java code, if it doesn't already exist... for example, if you've built the interface specification first as a WSDL file and a set of related XSDs, and then you want to build an implementation from there. -- www.designacourse.com The Easiest Way To Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation
Axis2 DIME Attachments
Hello, I've implemented an axis 1.1 client towards a gSoapService which returns DIME attachments; looks like it is working well! I've re-implemented the client using OMElement of Axis2 , but the ServiceClient is not able to create correctly the SOAPMessage, it throws the following error: org.apache.axis2.AxisFault: Invalid UTF-8 middle In the axis1.1 into the Call object I've set _call.setProperty(Call.ATTACHMENT_ENCAPSULATION_FORMAT, Call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME); I believe this could be the cause since I cannot find how to do the same in Axis2. Any suggestions, kind regards Alessandro
Re: Order of SOAPHeader and SOAPBody
Hi Xinjun, There was a known bug in SOAPEnvelope, which is the same pointed out also. I fixed it and now you can add SOAPHeader now to SOAPEnvelope and that will be added properly now. -- Chinthaka Xinjun Chen wrote: I found a walk-around. envelope.getBody().insertSiblingBefore(headerElm); This will add the header OMElement into the envelope. However, the Header added is only considered as a child element of envelope, not a SOAPHeader. Thus if I call envelope.getHeader(), I will get exception. Regards, Xinjun On 4/5/06, Xinjun Chen [EMAIL PROTECTED] wrote: I am using the following function to add UsernameToken to my security header. But the processed envelope get some problems. 1. The Header is placed after the body. How can I insert SOAPHeader before SOAPBody? 2. The security header defines the xmlns:xsd and xmlns:xsi again, which have already been defined in SOAP-ENV:Envelope. Could you give me some advice on how to solve the above two problems? Attached: 1) The function used for adding username token to the envelope: public void addUsernameTokens(UsernameToken token, final SOAPEnvelope envelope) throws Exception { Document domDoc = Axis2Util.getDocumentFromSOAPEnvelope(envelope); WSSAddUsernameToken builder = new WSSAddUsernameToken(, false); if (token.isDigested()) { builder.setPasswordType(WSConstants.PASSWORD_DIGEST); } else { builder.setPasswordTyp(WSConstants.PASSWORD_TEXT); } builder.build(domDoc, token.getUsername(), token.getPassword()); Element header = (Element) (domDoc.getElementsByTagName(wsse:Security).item(0)); OMElement headerElm = (OMElement) (Axis2Util.toOM(header)); SOAPFactory factory = Axis2Util.getSOAPFactory(envelope); factory.createSOAPHeader(envelope); envelope.getHeader().addChild(headerElm); } 2): The original soap envelope: ?xml version='1.0' encoding='utf-8'?SOAP-ENV:Envelope xmlns:SOAP-ENV=http://www.w3.org/2003/05/soap-envelope; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd=http://www.w3.org/2001/XMLSchema; SOAP-ENV:Body sayHello xmlns=http://services/helloworld; valueHello world!/value /sayHello /SOAP-ENV:Body /SOAP-ENV:Envelope 3): The processed soap envelope: ?xml version='1.0' encoding='utf-8'?SOAP-ENV:Envelope xmlns:SOAP-ENV=http://www.w3.org/2003/05/soap-envelope; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd=http://www.w3.org/2001/XMLSchema; SOAP-ENV:Body sayHello xmlns=http://services/helloworld; valueHello world!/value /sayHello /SOAP-ENV:Body SOAP-ENV:Headerwsse:Security xmlns:wsse=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd=http://www.w3.org/2001/XMLSchema; wsse:UsernameTokenwsse:Usernamexinjun/wsse:Usernamewsse:Password Type=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText;password/wsse:Password/wsse:UsernameToken/wsse:Security/SOAP-ENV:Header/SOAP-ENV:Envelope signature.asc Description: OpenPGP digital signature
Re: [Axis2-0.95] how to ectract SOAP fault information at client side?
Andreas Bobek wrote: Hi, In AxisFault(Throwable cause) only the message is extracted from cause... There again is a todo item: TODO: handle AxisFaults or SOAPFaultException implementations differently? YES ;-) Is this a hint or you wanna say sth else ? Or is there another possibility to get the SOAP fault information? options.isExceptionToBeThrownOnSOAPFault(false) -- Chinthaka signature.asc Description: OpenPGP digital signature
Re: Generating Web Service with Axis 1.3
Hi Chris,Thanks for your answer.But, IMO, tools should work for us as much as possible. I don´t want to write WSDD files myself, I want some tool to make that for me. Axis can do that, but still there is some job to be done. RegardsDanielOn 4/5/06, Chris Smith [EMAIL PROTECTED] wrote: Daniel Destro wrote: Axis code generation process seems to be a little bit cumbersome, because, first of all, I have to create the WSDL, then the server-side classes are generated from the WSDL. It would be much easier if we could do it with only one single step and it could also use my original business class instead of make me add code to delegate the calls from the XXXImpl class to the business class. If you already have both the WSDL and the implementation classes, then youdon't need to use WSDL2Java at all.Instead, you would just write a WSDDfile pointing to your existing WSDL and Java code.You would need to include type mappings in that file, potentially using bean serializers oreven custom serializers if your data classes are not beans.This will notbe a trivial process, since you need to match your existing code to the existing WSDL interface, and there may be problems on either side.WSDL2Java is meant to generate Java code, if it doesn't already exist... forexample, if you've built the interface specification first as a WSDL file and a set of related XSDs, and then you want to build an implementation fromthere.--www.designacourse.comThe Easiest Way To Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical TrainerMindIQ Corporation
(OT) Making WSDL pretty?
Hello, (Apologies for the semi-offtopic post...) Does anybody know of a tool that one can use to generate a human-readable version of a WSDL file? I am working on a little SOAP service to wrap around a number-crunching engine (written in Perl and C). The programmer of the engine is even less experienced on WSDL than I am, so it would be useful to be able to have a nicely formatted version of the service's WSDL file so we can discuss the signatures of the operations, for example. So far the options I found were: - Print Screen's of the Eclipse WSDL editor - A little ad-hoc XML parser that I wrote from some code samples from the 'Net (so far it generates Twiki-fied text that I can cutpaste to our Twiki) Obviously none of these options is too elegant, and Google is not being much help here either :-( Is there an official tool for this type of job? Thanks in advance, Hernan __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Re: Order of SOAPHeader and SOAPBody
Hi Xinjun,As I can see you are trying to add some Security to your Web Services, right?Are you doing a User Authentication / Authorization using this UsernameToken?I need to do that!How do add UsernameToken into to the SOAP request and how do u read / validate UsernameToken from the SOAP request (server-side) ??? ThanksDaniel
AW: [Axis2-0.95] how to ectract SOAP fault information at client side?
Hi Eran, it was not considered to be a hint. It was a suggestion, since the todo was formulated as a question. Currently there is no possibility to extract the SOAP fault details (Code, SubCode, Detail, Reason) at client-side. That's why for me the answer to the todo-question is 'yes'. I set options.isExceptionToBeThrownOnSOAPFault to true (although as I saw it is the default value). But the returned exception consists only of a message string and not of all the fault details which were sent back to the client. Regards, Andreas Bobek. -Ursprüngliche Nachricht- Von: Eran Chinthaka [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 5. April 2006 18:09 An: axis-user@ws.apache.org Betreff: Re: [Axis2-0.95] how to ectract SOAP fault information at client side? Andreas Bobek wrote: Hi, In AxisFault(Throwable cause) only the message is extracted from cause... There again is a todo item: TODO: handle AxisFaults or SOAPFaultException implementations differently? YES ;-) Is this a hint or you wanna say sth else ? Or is there another possibility to get the SOAP fault information? options.isExceptionToBeThrownOnSOAPFault(false) -- Chinthaka
Re: Order of SOAPHeader and SOAPBody
Hi, If you are using Axis2 you can use the Axis2 security module [1] to do this. Please see this simple how-to [2] document and try it out. Example: client's configured axis2.xml file - [3] the service's services.xml file - [4] Thanks, Ruchith [1] http://www.apache.org/dyn/mirrors/mirrors.cgi/ws/axis2/modules/wss4j/0_95/security-0.95.mar [2] http://ws.apache.org/axis2/0_95/security-module.html [3] https://svn.apache.org/repos/asf/webservices/axis2/trunk/java/modules/integration/test-resources/security/s1.client.axis2.xml [4] https://svn.apache.org/repos/asf/webservices/axis2/trunk/java/modules/integration/test-resources/security/s1.service.xml On 4/5/06, Daniel Destro [EMAIL PROTECTED] wrote: Hi Xinjun, As I can see you are trying to add some Security to your Web Services, right? Are you doing a User Authentication / Authorization using this UsernameToken? I need to do that! How do add UsernameToken into to the SOAP request and how do u read / validate UsernameToken from the SOAP request (server-side) ??? Thanks Daniel
Problem using deployed Axis web services
Dear all, my first posting here, so please bear with me, in case I should break any unwritten rules. I am currently trying to get my first web services up and running on Tomcat 5. I created a simple Java class to return a String: public class SayHello2 { public String hello(String in) { return (Hello, + in); } } From this class I created the WSDL with Java2Wsdl. I created the deployment descriptor using Wsdl2Java and deployed the whole thing using the Axis AdminClient. Finally, I compiled the resulting classes from step 2 and copied them to the directory that corresponds to the package name. The web service is listed together with the method in the list provided by Axis. However, I can not access the method, neither entering the direct URL (http://localhost/WSTest/services/SayHello2?in=bla), nor using the stub classes generated by Axis, nor using a org.apache.axis.client.Call. I am quite lost. Does anyone have any ideas what I could check? I've pasted the WSDL below, just in case there's any hint in there. (I can access this wsdl alright with http://localhost/WSTest/services/SayHello2?wsdl). Cheers, N. ?xml version=1.0 encoding=UTF-8? wsdl:definitions targetNamespace=urn:testPackage xmlns:apachesoap=http://xml.apache.org/xml-soap; xmlns:impl=urn:testPackage xmlns:intf=urn:testPackage xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/; xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/; xmlns:wsdlsoap=http://schemas.xmlsoap.org/wsdl/soap/; xmlns:xsd=http://www.w3.org/2001/XMLSchema; !--WSDL created by Apache Axis version: 1.2.1 Built on Jun 14, 2005 (09:15:57 EDT)-- wsdl:message name=helloResponse wsdl:part name=helloReturn type=soapenc:string/ /wsdl:message wsdl:message name=helloRequest wsdl:part name=in type=soapenc:string/ /wsdl:message wsdl:portType name=SayHello2 wsdl:operation name=hello parameterOrder=in wsdl:input message=impl:helloRequest name=helloRequest/ wsdl:output message=impl:helloResponse name=helloResponse/ /wsdl:operation /wsdl:portType wsdl:binding name=SayHello2SoapBinding type=impl:SayHello2 wsdlsoap:binding style=rpc transport=http://schemas.xmlsoap.org/soap/http/ wsdl:operation name=hello wsdlsoap:operation soapAction=/ wsdl:input name=helloRequest wsdlsoap:body encodingStyle=http://schemas.xmlsoap.org/soap/encoding/; namespace=urn:testPackage use=encoded/ /wsdl:input wsdl:output name=helloResponse wsdlsoap:body encodingStyle=http://schemas.xmlsoap.org/soap/encoding/; namespace=urn:testPackage use=encoded/ /wsdl:output /wsdl:operation /wsdl:binding wsdl:service name=SayHello2Service wsdl:port binding=impl:SayHello2SoapBinding name=SayHello2 wsdlsoap:address location=http://localhost/WSTest/services/SayHello2/ /wsdl:port /wsdl:service /wsdl:definitions -- -- Martin Wunderlich, M.A. Translation/Localisation EN - DE www.martinwunderlich.com -- Free / open-source software for translation/localisation: www.martinwunderlich.com/foss-links.html -- Random aphorism: Es ist ein Wunder, dass Neugier die Schulbildung überlebt. It is a miracle that curiosity survives formal education. - Albert Einstein --
RE: (OT) Making WSDL pretty?
Jay, Thanks for the links, I'll take a look at them. Actually, I was looking for something that formats the WSDL so the datatype definition section resembles more a classical datatype definition. The graphical view of the Eclipse WSDL editor is a good example (a little tree view with pretty-looking boxes and arrows). Unfortunately it doesn't have a print option, or an export to PDF option. ... that I know of, of course! :-) Thanks, Hernan --- Jay Glanville [EMAIL PROTECTED] wrote: If you want to change the indenting of the WSDL to make it easier to read, use something like HTML Tidy (http://tidy.sf.net). It can handle XML as input and output formats. If you want something to extract the annotationdocumentation values out of your WSDL and generate a set of HTML pages for human-readable consumption, do a Google on wsdldoc. I think IBM had such a tool in it's emerging tool kit. I believe that bluetetra also has one (http://www.bluetetra.com/). JDG -Original Message- From: Hernan Bay Area Guy [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 05, 2006 12:37 PM To: axis-user@ws.apache.org Subject: (OT) Making WSDL pretty? Hello, (Apologies for the semi-offtopic post...) Does anybody know of a tool that one can use to generate a human-readable version of a WSDL file? I am working on a little SOAP service to wrap around a number-crunching engine (written in Perl and C). The programmer of the engine is even less experienced on WSDL than I am, so it would be useful to be able to have a nicely formatted version of the service's WSDL file so we can discuss the signatures of the operations, for example. So far the options I found were: - Print Screen's of the Eclipse WSDL editor - A little ad-hoc XML parser that I wrote from some code samples from the 'Net (so far it generates Twiki-fied text that I can cutpaste to our Twiki) Obviously none of these options is too elegant, and Google is not being much help here either :-( Is there an official tool for this type of job? Thanks in advance, Hernan __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Re[2]: Problem using deployed Axis web services
Thanks a lot for the quick replies, Jinyuan. I checked WSDL2Java for the JUnit option you mentioned, but couldn't find it. As for the URL I call the web service with, it's a bit different from the one you provided. I tried the following: http://localhost/WSTest/services/SayHello2?method=helloin0=Bla and http://localhost/WSTest/services/SayHello2?method=helloin=Bla Neither of this works. I have also pasted the client code below. This only returns a null value. Cheers, Martin The generated code won't get Endpoint address right. Yours is http://localhost/WSTest/services/SayHello2. See if the following code or something simailar can help: call.setTargetEndpointAddress( new java.net.URL(http://localhost/WSTest/services/SayHello2;) import javax.xml.rpc.ParameterMode; import org.apache.axis.Constants; import org.apache.axis.client.Call; import org.apache.axis.client.Service; public class TestClient { public static void main(String [] args) { try { String endpoint = http://localhost/WSTest/services/SayHello2;; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress( new java.net.URL(endpoint) ); call.setOperationName(hello); call.addParameter( in, Constants.XSD_STRING, ParameterMode.IN ); call.setReturnType( Constants.XSD_STRING ); String ret = (String) call.invoke( new Object[] { bla } ); System.out.println(return: + ret); } catch (Exception e) { System.err.println(e.toString()); } } }
RE: Re[2]: Problem using deployed Axis web services
http://ws.apache.org/axis/java/reference.html -t builds testClient good luck, -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Martin Wunderlich Sent: Wednesday, April 05, 2006 3:57 PM To: Jinyuan Zhou Subject: Re[2]: Problem using deployed Axis web services Thanks a lot for the quick replies, Jinyuan. I checked WSDL2Java for the JUnit option you mentioned, but couldn't find it. As for the URL I call the web service with, it's a bit different from the one you provided. I tried the following: http://localhost/WSTest/services/SayHello2?method=helloin0=Bla and http://localhost/WSTest/services/SayHello2?method=helloin=Bla Neither of this works. I have also pasted the client code below. This only returns a null value. Cheers, Martin The generated code won't get Endpoint address right. Yours is http://localhost/WSTest/services/SayHello2. See if the following code or something simailar can help: call.setTargetEndpointAddress( new java.net.URL(http://localhost/WSTest/services/SayHello2;) import javax.xml.rpc.ParameterMode; import org.apache.axis.Constants; import org.apache.axis.client.Call; import org.apache.axis.client.Service; public class TestClient { public static void main(String [] args) { try { String endpoint = http://localhost/WSTest/services/SayHello2;; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress( new java.net.URL(endpoint) ); call.setOperationName(hello); call.addParameter( in, Constants.XSD_STRING, ParameterMode.IN ); call.setReturnType( Constants.XSD_STRING ); String ret = (String) call.invoke( new Object[] { bla } ); System.out.println(return: + ret); } catch (Exception e) { System.err.println(e.toString()); } } }
Can't compile code with exceptions
Hi all, I too am having trouble with exceptions. I can't even compile my code. I added one method to my interface as follows: Family.java: __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Re: Order of SOAPHeader and SOAPBody
Hi Eran, Thank you! Did you fix the bug in Axis2 0.94 or 0.95? I am using Axis2 0.94. Must I upgrade to 0.95? Regards, Xinjun On 4/6/06, Eran Chinthaka [EMAIL PROTECTED] wrote: Hi Xinjun, There was a known bug in SOAPEnvelope, which is the same pointed out also. I fixed it and now you can add SOAPHeader now to SOAPEnvelope and that will be added properly now. -- Chinthaka Xinjun Chen wrote: I found a walk-around. envelope.getBody().insertSiblingBefore(headerElm); This will add the header OMElement into the envelope. However, the Header added is only considered as a child element of envelope, not a SOAPHeader. Thus if I call envelope.getHeader(), I will get exception. Regards, Xinjun On 4/5/06, Xinjun Chen [EMAIL PROTECTED] wrote: I am using the following function to add UsernameToken to my security header. But the processed envelope get some problems. 1. The Header is placed after the body. How can I insert SOAPHeader before SOAPBody? 2. The security header defines the xmlns:xsd and xmlns:xsi again, which have already been defined in SOAP-ENV:Envelope. Could you give me some advice on how to solve the above two problems? Attached: 1) The function used for adding username token to the envelope: public void addUsernameTokens(UsernameToken token, final SOAPEnvelope envelope) throws Exception { Document domDoc = Axis2Util.getDocumentFromSOAPEnvelope(envelope); WSSAddUsernameToken builder = new WSSAddUsernameToken(, false); if (token.isDigested()) { builder.setPasswordType(WSConstants.PASSWORD_DIGEST); } else { builder.setPasswordTyp(WSConstants.PASSWORD_TEXT); } builder.build(domDoc, token.getUsername(), token.getPassword()); Element header = (Element) (domDoc.getElementsByTagName(wsse:Security).item(0)); OMElement headerElm = (OMElement) (Axis2Util.toOM(header)); SOAPFactory factory = Axis2Util.getSOAPFactory(envelope); factory.createSOAPHeader(envelope); envelope.getHeader().addChild(headerElm); } 2): The original soap envelope: ?xml version='1.0' encoding='utf-8'?SOAP-ENV:Envelope xmlns:SOAP-ENV=http://www.w3.org/2003/05/soap-envelope; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd=http://www.w3.org/2001/XMLSchema; SOAP-ENV:Body sayHello xmlns=http://services/helloworld; valueHello world!/value /sayHello /SOAP-ENV:Body /SOAP-ENV:Envelope 3): The processed soap envelope: ?xml version='1.0' encoding='utf-8'?SOAP-ENV:Envelope xmlns:SOAP-ENV=http://www.w3.org/2003/05/soap-envelope; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd=http://www.w3.org/2001/XMLSchema; SOAP-ENV:Body sayHello xmlns=http://services/helloworld; valueHello world!/value /sayHello /SOAP-ENV:Body SOAP-ENV:Headerwsse:Security xmlns:wsse=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd=http://www.w3.org/2001/XMLSchema; wsse:UsernameTokenwsse:Usernamexinjun/wsse:Usernamewsse:Password Type=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText;password/wsse:Password/wsse:UsernameToken/wsse:Security/SOAP-ENV:Header/SOAP-ENV:Envelope