I am using Axis 1.4 to connect to web services provided by ClickTime, an outside vendor. Their underlying technology is Microsoft .net and it is very picky about the format of the request. It expects a SOAP header in this format:
<soapenv:Header><CredentialsSoapHeader xsi:type="WebServiceKeyCredentials" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns="http://clicktime.com/webservices/2.2/"><ns1:Key xmlns:ns1="http://clicktime.com/webservices/2.2/">xxx</ns1:Key><ns2:Password xmlns:ns2="http://clicktime.com/webservices/2.2/">yyy</ns2:Password></CredentialsSoapHeader></soapenv:Header> The key issues are that the xsi:type must have the xsi: prefix and the xmlns="http://clicktime.com/webservices/2.2/"> must not have a prefix. I've worked with Clicktime and confirmed with manually created requests that the request will fail if either of these is different. I am having difficulty getting Axis to generate a header that it will accept. Here is the simple code I am using to try to establish a connection. public void getinfo () throws Exception { DataExchangeSoapStub ctBinding = (DataExchangeSoapStub) new DataExchangeLocator().getDataExchangeSoap(); // set credentials element in SOAP header WebServiceKeyCredentials wskey = new WebServiceKeyCredentials("xxx","yyy"); String ctURI = new DataExchangeLocator().getServiceName().getNamespaceURI(); SOAPHeaderElement she = new SOAPHeaderElement("", "CredentialsSoapHeader", wskey); QName qn = new QName(Constants.URI_2001_SCHEMA_XSI,"type",Constants.NS_PREFIX_SCHEMA_XSI); PrefixedQName tn = new PrefixedQName(qn); she.addAttribute(tn,"WebServiceKeyCredentials"); ctBinding.setHeader(she); String userid = ctBinding.getUserID("c...@real.com"); return; } This generates the following request. <?xml version="1.0" encoding="UTF-8"?><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:Header><CredentialsSoapHeader type="WebServiceKeyCredentials" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0"><ns1:Key xmlns:ns1="http://clicktime.com/webservices/2.2/">xxx</ns1:Key><ns2:Password xmlns:ns2="http://clicktime.com/webservices/2.2/">yyy</ns2:Password></CredentialsSoapHeader></soapenv:Header><soapenv:Body><GetUserID xmlns="http://clicktime.com/webservices/2.2/"><EmailAddress>c...@real.com</EmailAddress></GetUserID></soapenv:Body></soapenv:Envelope> If I change the creation of the SOAP header to this SOAPHeaderElement she = new SOAPHeaderElement(ctURI, "CredentialsSoapHeader", wskey); then I get this request. <?xml version="1.0" encoding="UTF-8"?><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:Header><ns1:CredentialsSoapHeader type="WebServiceKeyCredentials" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns1="http://clicktime.com/webservices/2.2/"><ns1:Key>xxx</ns1:Key><ns1:Password>yyy</ns1:Password></ns1:CredentialsSoapHeader></soapenv:Header><soapenv:Body><GetUserID xmlns="http://clicktime.com/webservices/2.2/"><EmailAddress>c...@real.com</EmailAddress></GetUserID></soapenv:Body></soapenv:Envelope> Any ideas on how to get this request formatted in the required form? Will Axis2 work better? -- View this message in context: http://old.nabble.com/Problems-formatting-SOAP-header-tp26485922p26485922.html Sent from the Axis - Dev mailing list archive at Nabble.com.