I have been trying to call a mock server I made on POSTMAN from IIB flow that I deployed on local. But I am getting java.net.UnknownHostException: 77735a12-4076-4e16-af64-79f0f9b70b61.mock.pstmn.io I have tested the mock server after creating it, it works fine. But this time I am trying to hit it from outside POASTMAN. Do I have to include CORS headers here?
Related
I am trying to create a websocket server using spring boot and I find it very tricky. I have followed multiple tutorials but I keep failing.
For instance, I followed this tutorial https://spring.io/guides/gs/messaging-stomp-websocket/
I did everything exactly like it was described there. However, when I start the server and access the generated UI and try to connect to the server, I get
WebSocket connection to 'ws://localhost:8080/user' failed: Error during WebSocket handshake: Unexpected response code: 404
It's very unclear to me why it would try to connect to /user if I haven't even defined such endpoint.
When I try connecting through Postman to the address "ws://localhost:8080/gs-guide-websocket", I get the 400 code. No logs in the spring console.
Any hints/advices on how to make a simple websocket server using spring boot? Literally, every tutorial that I follow on the internet, doesn't work.
I have a spring cloud project with the following packaging structure
Controller (publishes Rest Endpoint)-->flow (business logic)-->service (calls Feign client with hysterix fallback setup )--> Feign client.
Auto-wiring is done in respective classes e.g. flow is auto-wired in controller and service is auto-wired in flow and so on.
I want to perform integration test, by calling the endpoint published by the controller. The problem is I don't have endpoint accessed by the feign client at the moment (neither original nor spring cloud contract stub is available).
How do I stub the call made by feign client in this case.
You can use Spring Cloud WireMock support and set up an endpoint manually before the tests are called. In the feign configuration you can point manually to an IP and port. The problem is that this test is pretty much useless cause as a consumer you're mocking the producer.
UPDATE
You have a Feign client that will be used to call some external API. What you can do is you can use Spring Cloud WireMock (or just WireMock) to setup a mock of that API. Then you can teach WireMock to behave as you wish and assert whether your client works fine. The problem with such an approach is such that since you, as a client, are setting up the WireMock instance, you can teach it to behave in the way that has nothing to do with the real API. For example you state that if you send a request to endpoint /foo with a method GET then you should get back "BAR" in the response. Then you write a test where your client sends GET # /foo and assert that BAR got properly returned. However that doesn't mean that the other API indeed has that endpoint. So this approach can give you false-positives. You can however use WireMock to assert whether you can properly react to faulty responses like malformed response etc.
In such cases, if you really want to check if you can communicate properly with an API that you don't control, is that you can write tests that will call that real API via a WireMock proxy, you record that traffic and convert it into stubs. You can watch about this more in my presentation here https://www.youtube.com/watch?v=ZyHG-VOzPZg
I have created a proxy service based on wsdl, which is not exposed, so can we create a simulator to test the proxy service.
Please help me the steps to create simulator using SBConsole, and i have developed the OSB service in 11gR1.
I do not understand the question a little, what do you mean by create simulator?
I can suppose that you want:
Send request to your created proxy? You can use for example SoapUI to achieve it. Import your soap project and then call request. Here you got sample.
Send request to created proxy, and then send it from osb to mock (your external service simulator)? To that purpose you also can generate mock from SoapUI. Sample to create mock is available here.
We have created an soap request and sending the request using WebServiceTemplate
WebServiceTemplate.marshalSendAndReceive(request)
As my client is not ready with the server. I am trying to handle this request in my local and planning to post some dummy response.
Can you help me how I can mock this response?
If you are using CXF, see my JUnit Rule utility project. It creates an Endpoint using JaxWsServerFactoryBean.
I am trying to write a very simple REST client using RestTemplate and Jackson JSON.
Tried such sample from spring.io Getting error 401 Authorization Required even on localhost or even if I include it into the same Tomcat6 Eclipse project where that REST WebService is running.
We don't require any authorization on that Web Service while in Dev or local environment,
and anyway I am an authorized user.
Is that something enforced by Spring RestTemplate?
Running client as Java application on Java 1.6.
I am new to REST and JSON.
No there is no enforced Authorization required by Spring's RestTemplate. You should be able to build or launch an example simple REST webservice and send requests to it with RestTemplate without receiving this response, so either the server you are sending the requests to or something inbetween is returning this response code. Can you share any more details of the service you are communicating with? Is it something internal or a public API which may require Authorization?