setSoapActionHeaderIfNotPresent treats the empty string same as null, result is no SOAPAction header gets sent. invocation fails. #39

Closed
buildlackey opened this Issue Mar 26, 2012 · 1 comment

2 participants

@buildlackey

Hi.

I am trying to talk to a web service that insists on having SOAPAction header set.. when i invoke via SOAPui i see this
header value:

SOAPAction:

with soap UI there is no value for the header, but the header is there nonetheless.

I wanted to replicate this by sending raw xml to the web svc via ws lite. I used the version of SOAPClient.send() that takes a parameter map and a blob of raw XML for the soap input msg... like this >

def response = client.send(       [SOAPAction: '' ],     xmlRequest  ) 

However, i ran into what seems like a bug in SOAPClient.setSoapActionHeaderIfNotPresent () -- This
method treats the empty string same as null, And the result is no SOAPAction header gets sent when an invocation is made.
This causes the server i am communicating to choke and send me back an error response.

I needed to send the header so I modified the method as shown below. I'm sorry I don't have time to create a full patch, but I'm hoping the fix I am suggesting will make it into your code base some how. Thanks in advance - Chris

the fix <<<<

private void setSoapActionHeaderIfNotPresent(HTTPRequest httpRequest, SOAPVersion soapVersion, String soapAction) {

    // if (!soapAction) {       // <<<< --- i changed this .. to the line below
    if (soapAction == null) {
        return
    }
    if (soapVersion == SOAPVersion.V1_1) {
        if (!httpRequest.headers[SOAP.SOAP_ACTION_HEADER]) {
            httpRequest.headers[SOAP.SOAP_ACTION_HEADER] = soapAction
        }
    } else if (soapVersion == SOAPVersion.V1_2) {
        httpRequest.headers[HTTP.CONTENT_TYPE_HEADER] += '; ' + SOAP.SOAP_ACTION_V12_HEADER + '="' + soapAction + '"'
    }
}
@jwagenleitner

Thanks for reporting the issue and the suggested fix. This fix should be published shortly after I push a v0.7 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment