Unable to record the soap request in wiremock using JAVA api - wiremock

I am trying to record the soap request via wiremock JAVA API,tried to record by using the below code but I couldn't see any stub mappings files in the mapping folder,Please help me out.
Request:
http://localhost:PORT_NUMBER/IntegrationServices/Bookings/BookFlow_v3 (With xml data in request)
//Staring the wiremock server
WireMockServer wireMockServer = new WireMockServer(options().port(HTTP_PORT).httpsPort(HTTPS_PORT));
options().notifier(new ConsoleNotifier(true));
WireMock.configureFor(HTTP_PORT);
WireMock.configureFor(HTTPS_PORT);
wireMockServer .start();
//Staring wiremock recording
wireMockServer .startRecording(recordSpec().forTarget("server name")
.onlyRequestsMatching(getRequestedFor(urlMatching("/.+"))).captureHeader("Accept")
.captureHeader("Content-Type", true).ignoreRepeatRequests());
System.out.println("Wiremock server started recording");
SnapshotRecordResult snapshotRecordResult = server.stopRecording();
List<StubMapping> stubMappings = snapshotRecordResult.getStubMappings();
Output: Getting stub size is zero but no error

Related

Substream Source(EntitySource) cannot be materialized more than once

I'am trying to implement file upload functionality in my application using Akka HTTP. I am using Akka version 2.5.32 and Scala version 2.11.12. I write a simple code with directive storeUploadedFile, like in documentation (https://doc.akka.io/docs/akka-http/current/routing-dsl/directives/file-upload-directives/storeUploadedFile.html):
def uploadFile: Route = (post & path("uploadFile")) {
storeUploadedFile("uploadFile", getDestination) {
(info, file) => complete(JsObject("path" -> JsString(file.getAbsolutePath)))
}
}
private def getDestination(info: FileInfo): File = File.createTempFile(tmpDir, info.fileName)
But when i try to send a request to my application:
curl -F "uploadFile=#data.csv" -X POST localhost:8080/uploadFile
I'll get internal server error and exception:
ERROR [ActorSystemImpl] - Error during processing of request: 'Substream Source(EntitySource) cannot be materialized more than once'. Completing with 500 Internal Server Error response. To change default exception handling behavior, provide a custom ExceptionHandler.
java.lang.IllegalStateException: Substream Source(EntitySource) cannot be materialized more than once
What should i do to upload file without this exception?

Embedded Jetty Server giving Same response for different urls , without restarting its not working,

I have developed the embedded jetty server to implement the rest service.
I have setup the eclipse project in the eclipse.
I have written the sample program which returns some details through rest url,
I was successfully compiled the program and created a Runnable jar.
I was successfully able to run the Jar files and the server started and running on the port which i gave ,
I have the testing url
http://localhost:1234/getuser/1
it gave me the user details in the response
<username>test1</username>
I ran the same url with different id no
http://localhost:1234/getuser/2
Again it gave me the same result,
`<username>test1</username>`
So i have restarted the server and then it got me the proper details,
<username>test2</username>
public static void main(String[] args) {
// TODO Auto-generated method stub
ServletContextHandler context = new
ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
Server jettyServer = new Server(1234);
jettyServer.setHandler(context);
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
jerseyServlet.setInitOrder(0);
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames", org.test.test.getuser.class.getCanonicalName());
try {
jettyServer.start();
jettyServer.join();
} catch (Exception e) {
e.printStackTrace();
} finally{
jettyServer.destroy();
}
}
Without restarting the jetty web server how to get the proper results.
Is there any thing i need to add in the code to get it worked.
or any settings i need to do for this auto refresh?
I have found the answer, jetty server was able to refresh automatically, there was a object refresh didnt happened in the back end, resolved it from myside and it worked

Amazon Lambda connectivity issue- API calls works sometimes , doesn't work other time

I am using Amazon Lambda to connect to an External Rest web service. My code is in Java
URL url = new URL("MYURL");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
JsonReader jsonReader = Json.createReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
The issue is sometimes this code runs perfectly fine, but sometimes, I do not get any response nor any exception. I am not changing anything in my code.
In AWS X-ray under Error and faults - Error comes as True.
How can I possibly debug this issue? or what could I be doing wrong?
Thanks for the help!

kie server response handling

I'm getting below error when I tried to hit kie server from java application
Exception in thread "main"
org.kie.server.client.KieServicesException: Error while creating
service response! The actual result type class
org.kie.server.api.model.KieContainerResourceList does not match
the expected type class
org.kie.server.api.model.KieServerInfo!
Can anyone please help me in resolving this
Getting error at below location in my code :
KieServicesClient client = KieServicesFactory.newKieServicesClient(config);
I suppose that you are using REST transport protocol in Kie server client.
It seems that you put wrong server URL parameter to your instance of KieServicesConfiguration. Correct URL looks like this:
http://<server>:<port>/<context>/services/rest/server
Your server URL seems to be:
http://<server>:<port>/<context>/services/rest/server/containers
Which is actually URL of endpoint for retrieving containers list in Kie server.

How to connect a standalone xmlrpc-client to gwt-enhanced xmlrpc-server?

I have a gwt-application and want to connect to it's xmlrpc backend via a standalone xmlrpc-client (written e.g. with Apaches' xmlrpc-library).
Assume the project creates a servlet called TestServlet connected to the URL /test/test providing a Method public int add(int a, int b).
Calling the deployed servlet (running in a jetty on port 8080) with the code shown below, I get this error message in jettys' log:
javax.servlet.ServletException: Content-Type was 'text/xml'. Expected 'text/x-gwt-rpc'.
Is there any easy way to connect such a standalone xmlrpc-client with the gwt-enhanced xmlrpc-server?
I read about xmlrpc-gwt - but I want to keept the gwt dependencies for that standalone client minimal.
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL("http://127.0.0.1:8080/test/test"));
config.setConnectionTimeout(60 * 1000);
config.setReplyTimeout(60 * 1000);
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Object[] params = new Object[] {new Integer(2), new Integer(3)});
Integer result = (Integer) client.execute("TestServlet.add", params);
System.out.println(result);
GWT's RPC protocol is not related to XML/RPC . It's loosely based on JSON but it is not considered public, so you should not rely on its current form for interoperability.