Hello all. I'm using xmlbeans as released with the Apache Axis2-1.3 distribution (axis2-xmlbeans-1.3.jar). The schema that I am trying to generate source/classes from is the WS-Security schema (http://schemas.xmlsoap.org/ws/2002/12/secext/secext.xsd).
I have successfully generated source code and compiled classes from the schema, and I have successfully constructed XML elements from these classes. Where I am running into problems is in putting them together in the appropriate parent/child hierarchy. Here are the relevant (hopefully) sections of the .xsd file: <xsd:element name="Security" type="wsse:SecurityHeaderType"/> <xsd:complexType name="SecurityHeaderType"> <xsd:sequence> <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"> </xsd:any> </xsd:sequence> <xsd:anyAttribute namespace="##other" processContents="lax"/> </xsd:complexType> <xsd:element name="UsernameToken" type="wsse:UsernameTokenType"/> <xsd:complexType name="UsernameTokenType"> <xsd:sequence> <xsd:element name="Username" type="wsse:AttributedString"/> <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute ref="wsu:Id"/> <xsd:anyAttribute namespace="##other" processContents="lax"/> </xsd:complexType> <xsd:element name="Password" type="wsse:PasswordString"/> <xsd:complexType name="PasswordString"> <xsd:simpleContent> <xsd:extension base="wsse:AttributedString"> <xsd:attribute name="Type" type="xsd:QName"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> As you can see, the Security element defines no child components, just a "type" attribute. This "type" attribute then contains just an xsd:any reference. Similarly with the UsernameToken, a "Username" child element is defined, in addition to an xsd:any reference. The Security element as we have defined it looks like this: <Security> <UsernameToken> <Username>myUserName</Username> <Password>myPassword</Password> </UsernameToken> </Security> Where I'm having trouble is trying to build up the appropriate document structure once I have all the pieces build. Since there are no inherent parent/child relationships (other than UsernameToken/Username), I can't figure out how to add the Password element to the UsernameToken, and similarly the UsernameToken to the Security. Here is a method I am using to build it: private static SecurityDocument buildSecurity(String username, String password) { // Create a new instance of a Security document SecurityDocument wsseTmp = SecurityDocument.Factory.newInstance(); // Add a Security element to it. SecurityHeaderType security = wsseTmp.addNewSecurity(); // Create a new instance of a UsernameToken document UsernameTokenDocument usernameTokenDoc = UsernameTokenDocument.Factory.newInstance(); // Add a UsernameToken element to it UsernameTokenType usernameToken = usernameTokenDoc.addNewUsernameToken(); // Put the username into the UsernameToken element AttributedString userName = usernameToken.addNewUsername(); userName.setStringValue(username); System.out.println("\n1. usernameTokenDoc.toString():\n"+usernameTokenDoc.toString()); // Create a new instance of a PasswordDocument PasswordDocument passwordDocument = PasswordDocument.Factory.newInstance(); // Add a PasswordString to it PasswordString passwordString = passwordDocument.addNewPassword(); passwordString.setStringValue(password); System.out.println("\n2. passwordDocument.toString():\n"+passwordDocument.toString()); //put it all together...somehow // TODO System.out.println("\n3. wsseTmp.toString():\n"+wsseTmp.toString()); return wsseTmp; } The output produced by the println's looks like this: 1. usernameTokenDoc.toString(): <UsernameToken xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext"> <Username>USERNAME</Username> </UsernameToken> 2. passwordDocument.toString(): <Password xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext">PASSWORD</Password> 3. wsseTmp.toString(): <Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext"/> I looked through the APIs for something like an "addChildElement()" type method to add generic XmlObject's to elements, but didn't find anything. Can anyone shed some light on this for me? I'm sure I'm missing something simple! Thanks so much for your time. Chris -- View this message in context: http://www.nabble.com/Having-issues-with-WS-Security-document-construction-%3AS-tp17364354p17364354.html Sent from the Xml Beans - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]