question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to call webservice using wiremock

See original GitHub issue

Hi ,

I am new to wire mock, I have written very simple Spring Rest webservice and I want to use wiremock to call this service instead my controler, can you help how can I modify code to make sure, I use wiremock. its very simple code as follow,

@Controller @RequestMapping(“/state”) public class StateController {

@RequestMapping(value = "/{code}", method = RequestMethod.GET)
public  @ResponseBody String getState(@PathVariable String code) {
    String result;
    if (code.equals("KL")) {
        result = "Kerala";
    } else if (code.equals("GJ")){
        result = "Gujarat";
    } else{
        result = "Default State";
    }
    return result;
}

urgent help appreciated!!!

Regards, Lirin.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:15

github_iconTop GitHub Comments

1reaction
Simran-Jit-Singhcommented, May 11, 2015

Hi Tom,

I am trying to post data to Wire mock using Rest Assured POST API. Rest Assured Syntax: given().contentType(“application/json”).and().body(“Your_body_here”).when().post(“http://some_url”);

Will something like this work: given().when().body(requestBody).post(url).contentType(“application/json”); or should i write a wrapper over Rest Asssured POST call to integrate with Wire Post. Something like this: public static void postToWireMock(String url,String requestBody,int responseCode){ stubFor(WireMock.get(urlEqualTo(url)) .withHeader(“Accept”, equalTo(“application/json”)) .willReturn(aResponse() .withStatus(responseCode) .withHeader(“Content-Type”, “application/json”) .withBody(requestBody))); given().when().body(requestBody).post(url);

0reactions
vayalaivadivelcommented, Apr 12, 2016

Hi Tom, Very interesting. Can we have any sample to test SOAP client using Wire Mock with soap request and soap response xml

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using WireMock with SOAP Web Services in Java
I'm WireMock's creator. I've used WireMock to mock a collection of SOAP interfaces on a client project quite recently, so I can attest...
Read more >
Working with SOAP - WireMock
SOAP APIs typically use the SOAPAction header to select the appropriate action for the call. Although you can sometimes avoid this, it's usually...
Read more >
Wiremock and how to emulate SOAP Calls | by Daniel S. Blanco
Add the @WebService annotation to the class containing the logic. · Add the @WebMethod annotation to each of the methods we want to...
Read more >
how to call webservice using wiremock · Issue #102 - GitHub
The only way you can get WireMock to create the XML file is by using the record function. So, if your service is...
Read more >
Introduction to WireMock - Baeldung
When a WireMock server is in action, we can set up expectations, call the service and then verify its behaviors. 2. Maven Dependencies....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found