SpringBoot SOAP without XSD file - spring-boot

First time to code a SOAP (and as a producer) in the same SpringBoot REST codebase.
With a simple Google search am able to do a quick refresher about SOAP:
https://www.baeldung.com/spring-boot-soap-web-service
https://spring.io/guides/gs/producing-web-service/
https://dzone.com/articles/creating-a-soap-web-service-with-spring-boot-start
That said, all tutorials requires to create an "XSD" file.
"Is there a way to create a producer SOAP without supplying the XSD file with SpringBoot?"
is the main question. As I haven't seen any tutorial not following the contract-first approach.
Also, have sub-questions that doesn't sound well for me:
Namespace, should this be PROD url or could be dynamic URL?
PortTypeName, any info what's this for?
LocationUri, is it similar to REST controller as the class request mapping url?
Schema, can this be done via Java beans only without any XSD/XML file through SpringBoot?
Apologies to ask many noob questions, but highly appreciate any informative answers.

Related

What is the difference between the HATEOAS and RESTful Api doc frameworks, such as Swagger2

The idea behind HATEOAS is actually very simple, that is, in response to a link containing other resources that the client can use to interact with the server, the client cannot know that the server workflow, but can know the next steps in the resource link from the root links, but only the link, not Request parameters and examples This is a far cry from the online documentation generated by Swagger2 (personal feeling)
On the other hand, when it comes to code writing, looking at Spring Hateoas or using Spring ApplicationListener is hard-coded, it feels very cumbersome and feels like no swagger2 annotations are easy to use.
This problem bothers me, I don't know if my API should use the Hatepas way

Web client for spring-data-rest CRUD endpoints?

Spring Data REST creates a CRUD web server with a discoverable API, so it seems it should be possible to write a generalized web client application for it. Is there such an application?
May be you are looking for a HAL browser
https://www.baeldung.com/spring-rest-hal
or
something like https://www.npmjs.com/package/angular-spring-data-rest
https://www.npmjs.com/package/angular4-hal
I hope you mean sample client stubs. Actually a web client cannot be generalized beyond the resources it has. That will not be quite meaningful.
You can try below with swagger. Using swagger here would be really convenient (over raml etc) since spring-data-rest generates swagger it self for you.
Take your swagger spec
Paste it at https://editor.swagger.io/.
Go Generate Client => Your favorite programming language.
Then it will generate sample client stubs for you in the language you have selected.
I think this should be the far most generalized point that makes sense.
-Addition-
The primary problem spring-data-rest has solved is abstracting out all the common functionalities attached to controller (ex: response/request mapping etc) and making them readily available and configurable, so that the developer no longer needs to re-invent/duplicate them every time when they are coding a new endpoint.
So as you have suggested generating client-stubs is completely out of spring-data-rest scope. Please read the documentation for more info.

Why is a SoapActionCallBack sometimes necessairy?

I'm working on a webservice client using Spring-WS. It's not my first webservice project, using Spring-WS. But I am new in this particular project.
We generate dao-objects by using the maven-jaxb2-plugin.
I'm using Spring-WS WebServiceTemplate, with a standard marshaller and unmarshaller set.
In a previous project, I could just do my webservice calls using:
webserviceTemplate.marshallSendAndReceive(new ObjectFactory().createSomeRequest());
In my current project, I need to provide a SoapActionCallback, provided with the SoapActionUrl.
webserviceTemplate.marshallSendAndReceive(new ObjectFactory().createSomeRequest, new SoapActionCallback("http://some-action-url.com/action"));
If I do not provide this SoapActionUrl, I don't get a result, and when debugging, I see a surpressed exception:
Couldn't get a SAX parser while constructing a envelope
I'd like to remove those SoapActionUrls. Using the correct generated objects by maven-jaxb2-plugin, should automatically refer to the correct actionurl?
I've googled this, but did not find too much info about it.
I'd like to know why I just could 'leave the SoapActionCallback' in the first case, and in the second case, I'm obligated to provide this.
I'm not aware of specific technology used on the server-side, as the webservices are developed by an external partner.
Can someone explain this?

Secure Spring REST Service using spring-security-oauth2 2.0.5.RELEASE

I have been searching for an example Spring Webservice which is being protected using oauth 2.0..
Looking around I found https://github.com/spring-projects/spring-security-oauth/tree/master/samples/oauth2 but there some files seems to be missing from the project.
Two things that I am looking for is :
When user authenticates, user name and password goes to /login.do , now I can not understand how this Servlet is being configured, if its not controller. web.xml is missing.
When I try to see how beans configured then applicationContext.xml is also missing. I am not able to find those files in order to see how things are configured.
Help Required :
Should I use annotation in order to configure my web service or xml configuration. I am willing to use the latest version, and leverage advanced configurations, for better security.
I have another Single page application ( HTML5 ) , which accesses data from this spring web service, which is being hosted on Google App Engine. My ultimate objective is to create a chrome plugin of (html5) pages and use my service from there..
Please suggest a better path so that I can achieve my objectives.
Best regards,
Shashank Pratap
Apologize for late reply.
1) Regarding Oauth2.0 implementation : Since GAE does not support Servlet 3.0 therefore, developer is restricted to servlet 2.5. Therefore I found that we are restricted to 1.0.5.RELEASE. I was able to configure it successfully.
Best Practice on GAE : Rather than following this approach, I would suggest others to use Google Endpoints. As it supports oauth2.0 as well as we can develop REST API relatively quickly.
Scale ability and Response time : Since I was using Spring dependency injection along with spring security, application responded slower than the combination of Google Endpoints and Google Juice, as juice does injection just in time, where as spring prepares everything as soon as new instance starts, which created problem for me.
2) Chrome Plugin is completely different story. :-)
Please correct if I am wrong.
Thanks,
Shashank Pratap

Cross-service linking for HATEOAS micro-services

I have a number of micro-services built with Spring Boot, so for a bit of fun, I thought I'd have a go at adding HATEOAS to them to help set up cross-resource linking. It seems to work quite nicely within a particular project, but I was wondering whether there's a good way to link across APIs. As an example, imagine I have 3 services:
A user details service:
Code:
/users/{userid}
A user calendar service:
Code:
/users/{userid}/appointments
/users/{userid}/appointments/{appointmentid}
A user messaging service:
Code:
/users/{userid}/messages
/users/{userid}/messages/{messageid}
To make this browsable via the API, it would be good to have links from a user resource to its appointments and messages. Similarly, it would be nice to have links back from those resources. This is all very achievable when I have a single API with everything on the classpath, where I can write code such as:
Code:
user.add(linkTo(methodOn(CalendarController.class).appointments(user.getKey())).withRel("appointments"))
However I'm not able to do this if CalendarController is not on the classpath of the service I'm currently hitting.
Is there a good/recommended method for creating links to controllers which are not in the current project?
Referenced from spring forums
Maybe this is a bit more involved than you were hoping, but as mentioned here, this is exactly what Eureka is for. It also has really nice integration with the new Spring Cloud project.

Resources