cancel
Showing results for 
Search instead for 
Did you mean: 

Request headers not received in REST mock service after deploying in server

Occasional Contributor

Request headers not received in REST mock service after deploying in server

After deploying my rest mock service in server, I am not able to receive my request headers

9 REPLIES 9
Community Hero

Re: Request headers not received in REST mock service after deploying in server

What type of server?

 

How are you trying to get the headers?

Occasional Contributor

Re: Request headers not received in REST mock service after deploying in server

Server type: Apache tomcat

def requestBody = mockRequest.getRequestContent()

def abc_1= mockRequest.request.getHeader('abc').toString()
Using the above way, i am fetching the header and storing it in a variable.

Community Hero

Re: Request headers not received in REST mock service after deploying in server

Worked for me.

Apache Tomcat/7.0.69
JVM Version: 1.8.0_152-b16 (Oracle Corporation)
SoapUI 5.4.0

I created a MockService that returns the "success" response when the header is present (using your code in the dispatch script):

if (mockRequest.request.getHeader("abc") == '123') 
    return "success" else return "fail"

I ran the MockService in SoapUI and ran the request with abc header set to 123, and the response was the "success" result.

 

I ran "Deploy Project as WAR" and generated headers.war. I opened the Tomcat Manager webapp and deployed headers.war.

 

I changed my SoapUI request endpoint from localhost:8080/abc (UI mockservice) to localhost:9090/headers/abc (Tomcat deployment),sent the same request, and again got the "success" reply.

Occasional Contributor

Re: Request headers not received in REST mock service after deploying in server

Could you please explain how to create headers.war file?I did not create that file because of which i might not be  able to get the headers

Community Hero

Re: Request headers not received in REST mock service after deploying in server

Just choose Deploy As War from the Project menu in SoapUI.

Occasional Contributor

Re: Request headers not received in REST mock service after deploying in server

sorry i misunderstood that i have to generate war file with headers alone.Now i understood that it is the name of the war file.

Actually i had generated war file and deployed it, but when i hit it from soap ui to that particular url it is working fine. However, when the other component of my application tries to hit the mock service url, in my mock service log,I could see the request body content but header value(abc) is showing as null.

Community Hero

Re: Request headers not received in REST mock service after deploying in server

Are you sure only it's a problem when you deploy as WAR?

 

Can you try getting this "other component of your application" to send a request to the SoapUI mockservice (within SoapUI)?

Occasional Contributor

Re: Request headers not received in REST mock service after deploying in server

I couldn't hit my mock from other component because of set up issue. Instead i tried from postman and i got only response like "There are currently 1 running SoapUI Mockservices" not my oringinal response.

Community Hero

Re: Request headers not received in REST mock service after deploying in server

That response normally means you aren't requesting the full resource.

For instance, if your mock service is on localhost:8080/abc and you request localhost:8080/ then you will get that response.
New Here?
Join us and watch the welcome video:
Join the exciting event
SeptemberHubBub
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win