Spring WS produces notification instead of request-response - java

I've been attempting to create a port of an existing JAX-WS Web Service in Spring, using Spring WebService (following their guide loosely at https://spring.io/guides/gs/producing-web-service/).
I've got an endpoint working, using both the XSD the existing application (with JAX-WS) uses, and by generating a new set with SoapUI.
For some reason, the Web Service seems to be publishing with the Type of 'Notification', rather than 'Request-Response' like the original, existing methods on the pre-existing JAX-WS endpoint. The Spring WS also has an 'Output' with a Response-suffixed class stated, where the JAX-WS one does not. This is visually different in SoapUI with the Spring wsdl having a red 'left arrow' next to each method, instead of the contraflow arrows.
I think this is manifesting itself as an issue I'm seeing when I call the one endpoint I have set up - an error is logged stating 'No endpoint mapping found for [SaajSoapMessage .... myEndpointMethodResponse" (e.g. the response object from the endpoint method, not the endpoint method itself).
As mentioned, I feel like the 'Type' on the methods is the smoking gun, but I can't see what is causing it. I have looked up the issue but can't find anything common?
Update The following helped with the request-response (Invalid wsdl generated by spring-ws when the request element doesn't end with 'Request'), but I'm now getting a response back in SOAPUI of 'No adapter for endpoint' referencing my Response class. The PayloadRoot and ResponsePayload match the wsdl objects exactly.

OK, as the only 'help' on here was a close vote (thanks, very helpful), I've managed this myself now and will post the solution. There were two parts:
As per the 'update' in the question, the Request methods in the XSD were named after the method, and weren't suffixed 'Request'. This meant that I had to make a custom WSDL11Definition class that would allow the setRequestSuffix to be null (empty). The question link has more details.
The objects on the method needed to be wrapped in JAXBElement<> in order to recognise the input and output successfully.
One all the above had been done, my breakpoint was hit in my IDE using SOAPUI.

Related

how to print the contents of a repository and make a repository on a REST server?

I'm starting to design a RESTful server with Java, using the Httpserver class. I have a couple of tasks to do let's start with one:
The user must be able to discover the uri with a Read (GET) call to a predefined URI: "/index"
Like this: GET /index -> {/a, /b, /c}
everything is contained in a repository (a folder), how do I link that folder to / index?
probably it's a simple thing, but I don't know where to start, I accept advice and even sources that you can consult. Thank you
I created the server and it works, I leave you the code server codeserver code
I also created an index page where I put all the call handling for the index page into it
indexPage
There are a number of ways you can do this
HATEOAS describes a way to return links as part of a response - see here https://en.wikipedia.org/wiki/HATEOAS
you could also use OpenAPI to provide documentation for your apis to describe what apis are available https://swagger.io/solutions/api-documentation/

Read the request stream multiple times

We have a Tomcat ValveBase class implementation that is doing the authentication for our servlet container apps. One way to authenticate our http REST calls is to sign them and then check the signature on the server side. We do this check in the ValveBase class.
The problem is that after we consume the InputStream of the request (for validating the signature), we pass the request (org.apache.catalina.connector.Request) to the next valve implementation and by the time it hits the servlet, the inputStream is gone. No content to be delivered, since it was consumed at the signature verification procedure.
In the javax.servlet api, you can use an HttpServletRequestWrapper to implement your own ServletRequest and pass the real request as a constructor argument. In that case, we were able to avoid the situation where the content was read only once, but in the case of the catalina Request, seemed to be more delicate than we thought. Any ideas? Thanks.
There is a long standing enhancement request open against Tomcat to support wrappers for use in Valves in a similar manner to Filters.
The bug includes a patch that is likely to need updating for Tomcat 7.0.x.
Given that you are already using a custom valve adding the patch may not be too much of a leap. With that patch in place, you should be able wrap the internal Request object and solve this problem in a similar manner to the Filter solution (which I assume involves saving a copy of the request body - watch out for DoS issues).
This is, of course, completely untested. As an incentive to try it, if it does work and you provide the updated patch (attach it to the Bugzilla report) I'll look at getting it included in Tomcat 8.0.x and 7.0.x (providing it doesn't require any changes to the existing API).

Inspect SOAP message with SOAP Handler without making configuration

I need to catch all SOAP request messages. The purpose of inspecting SOAP request messages is reading specific value (such as IP adress).
I read this tutorial
http://www.mkyong.com/webservices/jax-ws/jax-ws-soap-handler-in-server-side/
But as far as I can understand, when I need to add handler on my project,
an annotation must be added like
#HandlerChain(file="handler-chain.xml")
And also handler-chain.xml must be implemented.
--
So, I'm going to implement a library to get all soap request IP adress and log them all. But if I use soap handler, I have to make some configuration on project that I added my library.
My purpose is creating Plug and Play library. If I add my library into a project, it must be start reading Ip adress from request message without making as above.
So, is it possible? How can I do it?
No it is not possible. Think about this logically. If your service does not make any call, does not create any objects (i.e. does not reference it the library in any way) then no code from that library will be run and therefore it will not be able to do anything. Using the message handler is the most minimalistic and least intrusive way I have found (and it is the way I do it) do handle such problem.

Inspecting request/response from Java/spring web service client

I have a client written in Java using the Springsource toolkit (that is, the #Service attribute) that is talking to an external webservice (completely seperate, nothing to do with my company) via HTTPS. I'm getting an exception on the marshalSendAndReceive step, which states that the content-type is coming back as text/html instead of the expected text/xml - with the message "could this be an error message?"
The webservice itself is the public test for the next version of the service, and calling the live service from the same code works fine. This particular method I am calling works fine on the live system but not on the test system.
My hunch is that the request is not correctly formatted for the test system - although only the response should have changed in the schema according to the release notes - and this is causing the service to return an error that is incorrectly parsed by my client. I am getting this error with all requests, even those that (according to the release notes) have not changed.
I have tried to use Fiddler and Wireshark to inspect the traffic, but can't get Fiddler to see it at all (I suspect this is a problem using Tomcat in STS with a proxy) and Wireshark can't decode the HTTPS stuff (I don't have the keys). I can't use HTTP, as the external service returns 403 Forbidden if I try.
I'm not the original developer, and I'm not even a Java developer. I am an experienced .NET developer, so any analogies with that will be understood - otherwise, I am a dummy and phrase your instructions/questions/possible help accordingly. As instructed by my predecessor, I have created a JAR file from the WSDL using XmlBeans and added that as a referenced library but I can't be sure that I've done that correctly, or even what it is that that is doing. It doesn't appear to have a discernable effect on things.
How can I debug this problem, and verify whether it is a problem with my client or their service?
My first goal would be getting Fiddler working. It is difficult to debug in the dark. However, where I get confused is when you discuss your client running in Tomcat in STS. Is your client a webapp?
Have you tried other tools like SoapUI to validate that the service is responding to your requests as expected?

How to match SOAP responses to the schema

Hi I am trying to evaluate a web service. I am using the Axis API to create the requests. I send requests with some attacks, and then want to validate the obtained response to the response schema. I don't have much idea as to how can I achieve this. Can some one help me to achieve this, or give me some pointers that would give me some idea to obtain this.
If you used the wsdl2java tool that comes with Axis2, the response message will be unmarshalled to the generated classes, and you will get an error if the reponse message does not correspond with the classes generated from the WSDL. So in this way you have a kind of implicit validation.
Jens-Martin is correct. If you're using the client generated by Axis wsdl2java, all the validation you need is happening behind the scenes. There are two kinds of validation going on:
SOAP has a schema definition, and the response must be a valid SOAP response or the client will throw an exception.
The WSDL you used to generate the client described what goes in the SOAP envelope of the response. If the response you get doesn't match, the client will throw an exception.
If you really feel compelled to write your own XML parser/validator and SOAP handler, you're on your own.
Try SOAPUI. It is quite a powerful open source testing tool for web services. You can construct test suites, do performance testing, and specify customized validation criteria.

Categories

Resources