Hi, I have a simple client generated from the wsdl. I'm using: axis-1.4.jar axis-jaxrpc-1.4.jar axis-saaj-1.4.jar wsdl4j-1.6.2.jar
I have the following simple call to post to a web service: import javax.xml.rpc.ServiceException; import javax.xml.soap.SOAPException; import org.apache.axis.message.MessageElement; import org.apache.axis.message.PrefixedQName; import org.apache.axis.message.SOAPHeaderElement; public class MyServiceWrapper { public static callService(String id, String URL, String username, String pass) { MyServiceLocator locator = new MyServiceLocator(); locator.setMyServiceEndpointAddress(URL); MyServiceSoapBindingStub service = (MyServiceSoapBindingStub) locator.getMyService(); // setup soap header SOAPHeaderElement header = new SOAPHeaderElement(new PrefixedQName("http://my.domain.com/webservices/type", "SessionInfo", "encoding")); MessageElement userElement = new MessageElement("", "User"); MessageElement passElement = new MessageElement("", "Password"); userElement.setObjectValue(username); passElement.setObjectValue(password); header.addChild(userElement); header.addChild(passElement); service.setHeader(header); // create query MyQuery myQuery = new MyQuery(); // set the id myQuery.setId(Long.parseLong(id)); // call the web service return service.doMyMethod(myQuery); } } If I call this inside...let's say in Eclipse it works fine. The web service is called..no errors, etc. However, the environment I have to run in is inside Mozilla JavaScript Rhino: http://www.mozilla.org/rhino/scriptjava.html This is an integration with a 3rd party, and I have no other choice but to do it this way. So the way this works, is there is some JavaScript file that calls the java code that does the above like this: importClass(com.my.domain.MyServiceWrapper); function callServiceWrapper( ) { MyServiceWrapper.callService(id, url, username, password); } However, in this kind of environment it does not work. Using WireShark to capture the raw packet data and see the SOAP exchange, I see that when it runs from the Rhino environment it base64 encodes the User/Password MessageElements. This is what it sends: <User xsi:type="ns1:String" xmlns:ns1="http://lang.java"><bytes xsi:type="xsd:base64Binary">YWRtaW4=</bytes></User> <Password xsi:type="ns2:String" xmlns:ns2="http://lang.java"><bytes xsi:type="xsd:base64Binary">YWRtaW4=</bytes></Password> When I run in a pure Java environment without Rhino, it does not do this. Same code, same libraries, same JDK -- the only difference here is Rhino. Our web service server blows up on the base64 encoded elements: <soapenv:Body><soapenv:Fault><faultcode>soapenv:Server.generalException</faultcode><faultstring>Error parsing username/password</faultstring><detail><ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">hostname</ns1:hostname></detail> Does anyone have a clue why this might occur, and how I can fix it? Thanks in advance, Davis