This problem has been bothering me for days. Hopefully someone has come across this before and has developed a workaround.
So I've developed a middleware Java app which during its execution invokes a SOAP action. Now, the behavior of this bit of code under the 1.6 JDK is working well:
// inside a try-catch block
SOAPConnectionFactory soapConnectionFactory =
SOAPConnectionFactory.newInstance();
SOAPConnection connection =
soapConnectionFactory.createConnection();
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMsg = messageFactory.createMessage();
String soapAction = getHeaderUrl() + "/" + method + "\r\n";
MimeHeaders headers = soapMsg.getMimeHeaders();
headers.addHeader("SOAPAction", soapAction);
// review the SOAPAction header
int header_count =
soapMsg.getMimeHeaders().getHeader("SOAPAction").length;
out("SOAPActions (from Soap header): ");
if (header_count == 0) out ("No SOAPActions defined.");
for (int i=0; i<header_count; i++)
out("SOAPAction["+i+"] = \"" +
soapMsg.getMimeHeaders().getHeader("SOAPAction")[i]
+ "\"");
SOAPPart soapPart = soapMsg.getSOAPPart();
StreamSource s = new StreamSource(new StringReader(msg));
soapPart.setContent(s);
soapMsg.saveChanges();
ByteArrayOutputStream req_bytes = new ByteArrayOutputStream();
soapMsg.writeTo(req_bytes);
String req = new String(req_bytes.toByteArray());
SOAPMessage reply = connection.call(soapMsg, Url);
However, when I use this exact same code under 1.3 or 1.4 JDK with the SOAP libraries linked, everything above works/compiles/executes, except for the fact that the SOAPAction field of the header is blank. Weirdly enough, when I check what the value of that header is (the lines immediately following setting up the header) the appropriate value is displayed. However, when it goes over the wire, the field is empty. As this is the field which indicates the resource I want to the processor, my messages are getting turned back at the door.
Has anyone encountered this problem before? If so, are there possible workarounds? (I am, of course, willing to use another library if required.)
UPDATE:
The libraries on my classpath are as follows:
- Xerces (resolver.jar, serializer.jar, xercesImpl.jar, xml-apis.jar)
- Saaj (saaj.jar)
- Axis (axis.jar
- JAX-RPC (jaxrpc.jar)
- Standard SOAP (activation.jar, mail.jar, soap.jar, xerces.jar)
- Commons logging and discovery
Thanks in advance!