How to use Wiremock to stub external URL? - wiremock

I want to stub an external request using Wiremock something like below:
WireMock.stubFor(post(urlEqualTo("https://rest.api.com/status"))
.withRequestBody(equalToJson("dummy-json"))
.willReturn(responseDefinition()
.withBody("json-body")
.withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)));
The stub is not getting called, and the code returns 401 unauthorized error.
I am using Spring Boot and have configured Wiremock as #AutoConfigureWireMock(port = 0, httpsPort = 8080)
Is there something I am missing in the configuration. I have tried using proxy and using WireMockRestServiceServer as described Spring cloud documentation.

You shouldn't call rest.api.com you should call localhost:8080. This is where WireMock starts.

Related

Making stubs permanent on wiremock

I am new to wiremock and would like to create permanent custom stubs. I was able to create stubs by running a standalone wiremock instance and sending post requests using curl commands to make the stubs. That works fine, but as soon as I restart the wiremock instance, all the stubs get lost. I was wondering if there was a way to make those stubs permanent, even after restarting the wiremock server.
When running wiremock for the first time, I tried doing record-mappings to permanently save the stubs, but that did not seem to work.
Thank you in advance!
When you add the stubs via curl (or the HTTP API generally), if you add a "persistent": true attribute to the stub JSON at the top level, WireMock will save it to disk.

What's the problem with Delphi Rest Client components

I'm trying to consume a simple API just for test, but it doesn't work using Delphi Rest Clients components.
Call to API works using browser and Postman without any configuration. The URL is https://api.cartolafc.globo.com/mercado/status
First I've tried use the tool "Rest Debugger" and it returns nothing.
So I tried to use the trio of REST CLIENT components by doing the following steps:
Created a new project;
Added TRestClient, TRestRequest and TRestResponse components;
Configured BaseURL from TRestClient as "https://api.cartolafc.globo.com/mercado/status"
Clicked the right mouse button on the TRESTRequest component
Hit Execute... command
It returns the following error:
Error receiving data: (12152) the server returned an invalid or unrecognized response
Did I do something wrong?

WebLogic 12c JAX-RS and JSON marshalling

I'm trying to deploy REST web service on WebLogic 12c. I followed the official guide to configure the Jersey runtime and deploy the service.
Everything seems to work, until I return any object from the REST method. Here is the snippet
#GET
#Produces(MediaType.APPLICATION_JSON)
public List<Foo> getFoos() {
return repo.getFoos();
}
The method returns "Internal server error" string as a payload. Oddly enough, I don't see any runtime exceptions in the server log. Same applies to any object type. However, I can return String with according media type with no problem.
Seems like there is some problem with the JSON marshalling. Do I need further configuration to enable the JSON marshaller?

Jboss fuse- running route with cxf endpoint in local camel context

I am working on a fuse project in Jbds. I am running a route as local camel context. It has cxf endpoint(soap), route started and started listening at /order/. If anyone has experience running camel context with cxf end point locally in the jbds, would you please let me know how to send soap message to this route which running in local camel context in jbds?
Are you looking to invoke webservice from java (client)?
you can use Service.create to create Service instances, the following code illustrates this process:
import java.net.URL;
import javax.xml.ws.Service;
URL wsdlURL = new URL("http://localhost/hello?wsdl");
QName SERVICE_NAME = new QName("http://apache.org/hello_world_soap_http", "SOAPService");
Service service = Service.create(wsdlURL, SERVICE_NAME);
Greeter client = service.getPort(Greeter.class);
For More info refer apache cxf documentation [1]
[1]http://cxf.apache.org/docs/how-do-i-develop-a-client.html
Please follow the steps to test the SOAP service exposed. The steps details are mentioned in the image link.Image for the steps to be taken.
See all the services exposed by CXF service (SOAP).
See the WSDL for the services exposed by CXF (SOAP).
Open SOAPUI and create new SOAP project.
Enter the details i.e WSDL URL in project detail.
The project will be displayed on the left-hand side.
Open the request in SOAPUI.
Fill the request and hit the green submit button.

XDS.b testing with SoapUI

I have to implement a simple client to a XDS.b server (SubmitObjectRequest and RetrieveDocumentSetRequest operations), but I'm struggling to get even a simple example of use to work.
I've tried using Mirth Connect's Channel for XDS.b also, but with no use. I even tried to copy its SOAP envelope to use with SoapUI. Didn't work.
I'm using HIEOS deployed on Glassfish as my XDS.b server.
I'm lost and confused. Could anyone give me a guidance on how to make this work?
If the HIEOS is deployed correctly within the Glassfish the service endpoint provides a wsdl definition where the interface is specified. Check the Glassfish for the wsdl of the service.
http://localhost:8080/my-ws/simple?WSDL
Quelle: docs.oracle.com/cd/E18930_01/html/821-2418/gbiyw.html
The list of provided endpoints you can see here:
https://kenai.com/projects/hieos/pages/WebServices
So to retrieve the wsdl you should use for example:
http://localhost:8080/axis2/services/xdsrepositoryb?wsdl
which applies for the ProvideAndRegisterDocumentSet-b transaction of the XDS Repository actor.
You can use the WSDL definition to create a WS request using SOAP UI at first.
SOAP UI creates a request based upon the wsdl definition which can be used to
test a against your XDS repo.
When you know how a SOAP request must be constructed you can try it using Mirth or
create your own client using Apache CXF http://cxf.apache.org/ for example.
Or you use AXIS2 to create a client from the WSDL. Of course does Visual Studio and C# also offer mechanisms to create a WS client directly from a WSDL definition.