Why is a SoapActionCallBack sometimes necessairy? - spring

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?

Related

Create an XML assertion sso-like with Spring

I'm kinda newbie into the spring world, and I'm trying to run a POC for a SAML SSO assertion-type,
I've implemented locally this project https://github.com/vdenotaris/spring-boot-security-saml-sample
And ran it against SSOCircle, but eventually, I'm gonna need to use my own IDP what I'm trying to do right now, doesn't involve actually validating the user, I want the demo project from the GitHub to point to a different spring project.
That part is actually done, I've added to my IDP-demo page an XML-metadata which is consumed by the Service provider, then in my IDP-demo, I type any email address and it should take me back to the Service Provider (the vdenotaris sample project) with a valid assertion.
How can I dynamically generate this XML assertion? I've read the spring docs and the SAML docs with no luck, If anyone can point me into the right place or even the proper documentation I'll be thankful.

SpringBoot SOAP without XSD file

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.

File upload with SPQR Graphql

I'm using spring boot and spqr graphql library. I need to upload a file(s) via graphql. I don't know what object type to expect in the service and I'm assuming that this isn't even supported.
Has anyone tried this? Any advice?
Thanks.
(Assuming you're using SPQR Spring Starter)
Uploading/downloading binaries is currently inconvenient in SPQR, but not impossible. You'd need to override the provided controller with your own and decide how you want to receive the queries and binaries, and how you want to send the results and binaries back. To override the controller, just provide your own bean of GraphQLController type.
Your best bet is implementing the GraphQL multipart request spec which thanks to Spring shouldn't be too complicated.
Btw you can always get to the raw request by injecting #GraphQLRootContext DefaultGlobalContext<NativeWebRequest> request as a method argument. From there you can obtain input and output streams.
You can also wire in a custom ArgumentInjector that can inject something more precise if you want.
In the near future, the starter will support the GraphQL multipart request spec out of the box.
If you're not using the starter, the situation is similar in that you're kind of on your own with implementing the transport for binaries and queries.
But, with all that said, it is generally a best practice to handle dealing with binaries outside of GraphQL completely (only send download URLs and such using GraphQL), so I highly recommend that approach if possible. The reason is that requiring optional specs breaks out-of-the-box compatibility with most clients.

Spring Data Rest modify Repository method URI

This may be a bit of a rudimentary question, but I have a repository where I can do a find by username as follows:
....../items/search/byUsername/?username=myusername
However, this is generally inconsistent with how AngularJS Resources treat queries. Is there a way to instead make the request URI for the same thing to be
....../items/?username=myusername
Or does that functionality not exist with spring data rest? custom methods can be made in the angular resource but it is tedious to do that for every possible search category
If Angular (read: a client library) defines what URI's have to look like, then it's fundamentally violating a core REST principle — which is that clients follow links and URI templates.
That said, if you're using Querydsl and let your repository extend QuerydslPredicateExecutor, collection resources can be filtered by using property expressions. See the reference documentation for details.
Another option would be to manually expose resources under the URIs expected and manually forward the calls. But again, I'd argue you're better off teaching Angular to behave like a proper REST client in the first place 🙃.

PUT method in jersey

I am new to Restful webservice. When I was going through the tutorials, I saw that PUT method can be used to create the resource. the creation means adding into the database or somewhere by implementing our own effort? or will Jersey take care of creating the resource its own?
Sorry for asking silly questions.. I did not get the way what PUT is doing..
Thanks
Bhanu
Jersey won't do anything except you tell it to. A PUT request semantically should create or update a ressource, so if you plan to create some entity, thats the HTTP method to use. Use #PUT to annotate your method and implement your functionality (as your tutorials tell you).

Resources