SOAP service and REST Client in one app - java

I am working on a webservice app that takes SOAP requests on one end with a id, I wrote java beans and generated wsdl. It is working fine independently. Then I made a REST Client using apache HttpClient using the interface CloseableHttpClient. This part works independently as well when I make a rest request with a static ID.
Now when I merged the REST client code with the soap service and try to test it using SoapUI, I get :
java.lang.reflect.InvocationTargetException.
The webservice is working fine but when I call the REST client the thread hangs up at when trying to execute.
CloseableHttpResponse response = httpclient.execute(post);
Im thinking there's some design issues with how I'm merging this. Right now, I'm calling im Instantiating the object that makes the rest call within the Soap Request class and calling the method from within the soap request class
Can anyone please help me point to the right direction about how I should design it. I was not able to find any examples on this either online
Thanks

Related

HTTP Status 405 - HTTP method POST is not supported by this URL - SOAP

I am using a SOAP service / client ( which is .NET) that sends XML envelopes to a SOAP UI service (Java I am guessing) however, we are getting a 405 saying method is not allowed, looking into fiddler, the error is actually HTTP method POST is not supported by this URL however this confuses me when using SOAP, I thought it uses POST by default as using a GET would put the XML inside the URL which is crazy. Does anyone know if I can change something in the client or in the service?
I just had a similar issue in SoapUi 5.2.1. I've exposed 30+ web service methods through Java on Jboss EAP 7. Originally I had 4 only exposed in my SoapUi project. When I re-updated/consumed the updated WSDL, the 26 new methods showed in SoapUi. I filled in all the sample requests with the needed arguments. I then created a "Test Suite" consisting of test cases for each of the new methods which "inherited" the arguments I had populated in the default requests (time saver!).
I executed the test suite. Everything passed as green, but looking at the resulting web service responses almost all of them had:
<html>
<head>
<title>Error</title>
</head>
<body>HTTP method POST is not supported by this URL</body>
</html>
As the SOAP response. I dug around a bit, it turned out to be only the new methods I had added, the four original worked fine. Looking at the SOAP endpoint, I realized I had modified the web service slightly and instead of the endpoint being:
http://localhost:8080/MyServicesR20/AdvancedBusinessService
It was now:
http://localhost:8080/MyServicesR20/AdvancedBusiness
For some reason when SoapUi updated the definition it didnt use the original endpoint for all the new requests and instead an older one. I manually went and changed each to be the correct endpoint and now all the web service requests work as expected.
Note and hindsight, if you have a large number of requests and or test cases and end up changing the endpoint, just back up the XML document that SoapUi uses for the project, then perform a search and replace of the old endpoint with the new endpoint to save yourself a lot of trouble!

SOAP POST method performs GET?

I have a SOAP webservice that is currently POST method, however I saw on my logs that when client is consuming my service there are two calls being made, 1 is to GET the wsdl file then POST to the webservice? Should it be POST call only?
You can think of the WSDL file as a sort of blueprint for a SOAP service. Given the WSDL, your client application can figure how to use the SOAP service. So I see nothing wrong with your client app first doing a GET to download the WSDL, following by a POST to actually consume the SOAP service.

SoapRequest as xml string

I have been working on an Android app and calling a WCF C# web service. I can call one of the methods correctly but having problems calling the other. Just to make sure it works, is there any way that I can use the XML request (I know that this is the XML request which the web service requires) using KSoap2? That is, can I use the XML Request as a string and set it as a parameter in order to pass that string request up to the web service, to see if I can add data to a database through the web service?
For anyone that's interested, the following post helped me solve the problem
http://mobileorchard.com/android-app-development-calling-web-services/

How to query a SOAP Service in Java

I would like to connect and query Trip Advisor's SOAP service. I currently have a WSDL for the service, and have connected to it using SOAPUI. I have been doing a lot of research about SOAP, but still am not sure I fully understand what I need to code in order to query the service as I would like.
The service takes an input of a simple place-id(I Have a list of many place-ids that I would like to query) Then it returns with the SOAP reply, which I would like to save as a new file(named place-id.SOAPrequest).
I have been doing reading on AXIS2, how to generate API code using SOAPUI, and launching a SOAP service in Netbeans.
I am currently trying to launch a AXIS2 service on my server, and then I assume load into it the java code that SOAPUI generating for the wsdl. But I don't know how to do this or if this is even the correct approch to the problem. Any suggestions or advice would be great.
See this step by step guide to Generate Java Axis 2 WebService CLIENT/SERVER

CXF: getting SOAP request and response XML on the client-side

I'd like to have a CXF client which allows me to see the SOAP XML request made and response received.
Use case: I'm writing a test GUI for the service for people who don't have access to my CXF service's logs to get an idea what the SOAP requests need to look like and what gets returned. (Since the interface is rather complicated, a generic / dynamic GUI like SOAP UI isn't helpful).
I've already read about CXF interceptors and know how I could hook them to my client (one for the "receive" and one for the "send" phase). But I can't think of a way of making the interceptor pass the request/response XML somehow back to the client's request.
Any suggestions / ideas?
You should take a look at the code of org.apache.cxf.interceptor.Logging{In|Out}Interceptor.

Categories