Forum Discussion

rgujjarl's avatar
rgujjarl
Regular Visitor
7 years ago

ERROR:java.lang.NullPointerException: Cannot get property 'message' on null object

Friends, I am trying to add "Content-Disposition" header to one of the parts of multi part SOAP request which is not adding by default if I use Inline Files feature of SoapUI Pro to send a file as an attachment. I have followed below KB article to add this part header using RequestFilter.filterrequest Event handler but I am getting "ERROR:java.lang.NullPointerException: Cannot get property 'message' on null object"

 

Any hints to fix this?

 

KB Article:

https://smartbear-cc.force.com/portal/KbArticleViewer?name=Troubleshooting-issues-with-adding-attachments-to-REST-requests&sp=all

 

My Groovy Script from RequestFilter.filterrequest Event:

import org.apache.http.client.methods.HttpRequestBase
import com.eviware.soapui.impl.wsdl.submit.transports.http.BaseHttpRequestTransport
 
HttpRequestBase httpMethod = (HttpRequestBase) context.getProperty(BaseHttpRequestTransport.HTTP_METHOD)

 

def count = context.getProperty("httpMethod").requestEntity.message.content.count
for (def i=1; i < count; i++)
{
def bodyPart = context.getProperty("httpMethod").requestEntity.message.content.getBodyPart(i)
bodyPart.removeHeader("Content-Disposition")
bodyPart.addHeader("Content-Disposition", "attachment; name=\"Base64Content.txt\"; filename=\"Base64Content.txt\"")
}

1 Reply

  • nmrao's avatar
    nmrao
    Champion Level 3
    Not sure. From the error, below statement is getting null.

    context.getProperty("httpMethod").requestEntity