Does Spring Cloud Contract DSL support bodyFileName - spring

I am trying to define a contract using spring-cloud-contract framework that for a specific request returns a response with big body. This body is always the same. So I would prefer to store this body in some static file. And generated Wiremock mapping would use bodyFileName to refer to that static file with response body content.

No it doesn't. But the DSL uses Groovy so you could theoretically download the body from somewhere. From the jar with stubs for example

Related

How to generate an OpenAPI from a Spring app without running the app?

I can run a Spring Boot application and then use the springdoc-openapi-maven-plugin artifact to generate an OpenAPI spec.
However, is there also a way to generate the spec without running the application first?
I currently want to generate the spec in a GitHub Action and a direct way would simplify this a lot.
you can use swagger editor: https://editor.swagger.io/
It allows you to write a json/yaml with your specifications and at the same time you can view the result.
Also, in the upper part there are 2 features, which allow you to generate the code based on the json/yaml made.
For example you can create a spring application with all the endpoints you go to specify in your json/yaml ( server).
But you can also generate HTML. (Client)

How to validate a SOAP request against a WSDL (yes, WSDL, not XSD), in ruby

I have, in the context of a SOAP request,
a WSDL
a bunch of XSDs, referenced by the WSDL
an example SOAP request
I would like to validate that the SOAP request fits the WSDL and all the XSDs.
I am specifically looking for a dead simple (as in lines-of-code) way using existing gems. I know, in principle, how to do it myself by extracting all the XSDs from the WSDL and validating the XML against the XSDs myself (with nokogiri, for example), but in the context of this question I am specifically looking for something as easy as
require 'wonderful_validator'
WonderfulValidator.validate(xml, wsdl)
The validator should be able, given that it can find all the files in the proper manner of course, to do everything needed to decide whether the XML fits the WSDL and all the XSDs. Including the SOAP header/body message structure.
Similar to Java. Validate SOAP message against a WSDL or http://www.soapui.org/apidocs/com/eviware/soapui/impl/wsdl/support/wsdl/WsdlValidator.html or https://www.codeproject.com/Articles/182406/Validating-SOAP-Message-against-WSDL , just in ruby.
There is a gem called wsdl_validator that pretty much tries to validate the SOAP request against WSDL before sending. However in my case , it fails to identify multiple schemas defined inside the WSDL.
In response to other people here: No, Savon does not automatically validate.

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?

Mocking Rest Api with Swagger Documentation

Whole idea is to create Mock service for UI guys to test without actual api.
- We have define specification in .ymcl files.
- Now want to generate Swagger-UI and Mock rest URI with mock data.
- Using spring-boot.
Please suggest some way to generate the same.
Given that you've the API documented in Swagger/OpenAPI spec (YAML format), you can use Swagger Codegen to generate Spring boot server stub.
Please pull the latest master of https://github.com/swagger-api/swagger-codegen and follow the instruction in the wiki:
https://github.com/swagger-api/swagger-codegen/wiki/Server-stub-generator-HOWTO#java-springboot

SOAP UI: Can I add assertion to validate with local XML Schema file?

I have created a Web Service (with Java, Axis). Depending on the content of the request, the response may have a different XSD. So, the WSDL only specifies that the response is of a generic XSD, and the responses comply to XSDs that import and extend the generic XSD.
Unfortunately, the Schema assertion fail because the XSD specified in the WSDL can only the generic one. Is there a way to manually specify which XSD I want the assertion to use? For instance, depending on the request I prepare, I know the specific XSD of the response. So, it would be perfect if I could say to SoapUI to assert the response by that XSD, which I can store either locally or at a url.
So, is there a way to make a schema assertion using a locally (or remotely) stored XML schema?
Thanks,
Markos
What I did after all is that I created a simple class to do this in Java.I exported the project as a jar, imported it in Groovy and just called it.
This is normal, as both Java and Groovy both play on the JVM, so it is perfectly normal to call classes and methods from one another.

Resources