Can a Soap webservice be accessed with the wsdl name ?? and also with the LocationUri? - spring

We have a soap-webservice defined through the Spring(spring-ws) and Spring is generating the wsdl through our config. And we have defined the end-point in our code as:
wsdl11Definition.setLocationUri(http://xyz:8080/dev/ws/abc);
and so the wsdl got generated with the Spring is :
http://xyz:8080/dev/ws/def.wsdl
and the below is what am seeing as the endpoint in the generated wsdl
<soap:address location="http://xyz:8080/dev/ws/abc"/>
But our clients are able to access our service with both of the below.
http://xyz:8080/dev/ws/def.wsdl http://xyz:8080/dev/ws/abc.
How does this work or is working.
Does Spring/tomcat routes or able to route the web-service calls coming in with either the endpoint-path of .wsdl name (def in above) too and also the one with the endpoint (abc in the above) to the end soap web service.
please share any insights, if any have on this. thanks much.

Related

How to remove context-root from generated swagger

I have am application that has a context-root set (property: quarkus.http.root-path).
Using quarkus-resteasy-reactive-jackson, a resource was created with a #Path annotation.
Now I want to generate OpenAPI documentation for my resource.
As I want to deploy this into a API gateway, I require a server property with a context root in the swagger.
I added a server entry using the mp.openapi.servers property.
The problem now appears that when there is a root-path property, the generated swagger resource path includes this root path, e.g.
quarkus.http.root-path=/sample
mp.openapi.servers=http://localhost:8080/sample
Resource annotated with #Path("resource")
It seems that the resource path includes the root-path.
So importing this swagger into the API gateway (or just clicking on the Try button), results in a url of http://localhost:8080/sample/sample/resource being attempted which ofc does not exist.
Is there a way to not to add the root-path to the resource endpoint in swagger? (I tried using mp.openapi.extensions.application-path.disable=true, but this had no effect)
I managed to get past this by doing the following:
dont set quarkus.http.root-path
quarkus.rest.path=/sample
quarkus.http.non-application-root-path=/sample/q
mp.openapi.servers=https://localhost:8080/sample
So just want to know if anyone know of a better way of doing this?

Cannot show the endpoint list when calling link without ?wsdl, but still can call the SOAP web service?

I have a web service with Spring and CXF like:
#Service
#WebService(serviceName = "ReceiveMultiFromVOfficeImpl")
#RequiredArgsConstructor
public class ReceiveMultiFromVOfficeImpl {
public Long returnSignReult(ResultObj resultObj) {
log.info("Start receive from Voffice...");
return 0L;
}
}
and my ws-endpoint-lazy-load.xml file config:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans">
<bean class="com.abc.fw.ws.CxfWsEndpointFactory">
<property name="endpoints">
<list>
<value>com.abc.bccs2.service.TestCustomService</value>
<value>com.abc.voffice.vo.ReceiveMultiFromVOfficeImpl</value>
</list>
</property>
</bean>
</beans>
When I call http://localhost:8082/services/pbh/ReceiveMultiFromVOfficeImpl?wsdl, it works and I can call SOAP. But when I call http://localhost:8082/services/pbh/ReceiveMultiFromVOfficeImpl, I expected it will show the endpoint's information. It shows error:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Fault occurred while processing.</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
What I want is something like:
How do I fix that?
I'm not sure you understand how a SOAP web service works, so here is some explanation about what you are seeing when accessing those URLs.
When dealing with a SOAP web service there is only one endpoint address to use to send messages to the web service and it is invoked over POST.
In your case:
POST http://localhost:8082/services/pbh/ReceiveMultiFromVOfficeImpl
is how you invoke the web service. As long as the web service is running and listening on that address, then a POST with a SOAP message will invoke the web service.
Because a SOAP web service can be described by a WSDL document, there must be some way to obtain the WSDL for the web service. By convention, it is accessible over a GET request at the web service endpoint by specifying a ?wsdl parameter.
In your case:
GET http://localhost:8082/services/pbh/ReceiveMultiFromVOfficeImpl?wsdl
will return the WSDL of the web service.
Any other GET/POST/URL comination will either return an error or will return some other information provided for convenience, assuming the web service framework used to build the web service does that. For example, this web service (http://www.dneonline.com/calculator.asmx) allows you to call its endpoint over GET and will return a human readable summary of what the WSDL accessible at (http://www.dneonline.com/calculator.asmx?wsdl) contains, but don't expect that to be the case with every framework out there (from what I remember CXF just returns an error if you call the web service endpoint over GET without a ?wsdl parameter).
So, to recap, the HTTP verbs and URLs valid for your web service are:
POST http://localhost:8082/services/pbh/ReceiveMultiFromVOfficeImpl -> to invoke the service
GET http://localhost:8082/services/pbh/ReceiveMultiFromVOfficeImpl?wsdl -> to obtain the service WSDL
Some other resources to read:
How is a SOAP call possible without WSDL?
The WSDL is not the SOAP web service
Is it mandatory to have a WSDL definition accessible using ?wsdl?
Finally, if you are using the proper URL and HTTP verb combination and you are getting that error, note that Fault occurred while processing is a generic error message that may show some issue with the web service code. Maybe there is a NullPointerException or some other error in your web service code. You need to look in your web service logs or in your web service console to see if there are any other exception messages or stacktrace that points to a root cause for that fault message.

SpringCloud Gateway redirect based on URL and Method

Springboot : 2.0.4.RELEASE
I am using Swagger documentation to create RouteDefincationLocator to redirect my incoming request to appropriate service in Spring.
Now there are some services who has same URL with different http method name. i.e
POST /v1/orders (This is more restricted then other url)
GET /v1/orders?view=single
Now in Spring cloud gateway I want to apply 2 different set of filter on each URL
i.e.
For : POST /v1/orders
Filters
ValidUser
Has Create Permission
For : GET /v1/orders?view=single
Filters
ValidUser
I have implemented RouteDefinitionLocator, and implemented method
public Flux<RouteDefinition> getRouteDefinitions()
I have also set predicates PredicateDefinition but this is only verifying URL Path and not method
There are lots of consumer of these services, so I can not change the URL
Can someone tell me how can I add different filters based on incomming URL+Method
Thanks in advance.

How to create soap service using GET method

I'm beginner to the soap web service. When I create soap service don't think about That service is POST or GET .But when we create REST service we initialize that service is POST or GET.
I created soap web service.Here is my code
#WebService(targetNamespace = "http://service.test.hameedia.com/", portName = "HameediaTestServicePort", serviceName = "HameediaTestServiceService")
public class SoapServiceTest{
public String details(String name){
//some thing in here
}
}
But in here we didn't initialize this is POST or GET .But console show this is POST method.My question is
Is soap web services default method type POST
If is it not
How to create soap web service with GET method
I get some idea from this.But I'm not clear with my question.If you have any idea about this please share.
SOAP is an acronym for Simple Object Access Protocol. It is an XML-based messaging protocol for exchanging information among computers. SOAP is an application of the XML specification.
SOAP is not depended upon HTTP and HTTP Method(s), SOAP can extend HTTP for XML messaging.
You can call SOAP Web Service over HTTP and you have to use POST method only because of complex nature of the SOAP Request.
Ref : https://www.tutorialspoint.com/soap/what_is_soap.htm

Where is the refreshToken endpoint implementation?

I am using springboot-security-jwt because have good recomendation, and it is running... But when I was testing refreshToken, where the implementation? How to use it?
Perhaps it is so obvious for a "Senior Developer Spring", but it is not for me, I not see it there. Where the /auth/token endpoint implementation?
There are some examples or documentation about it and how to (parameters) call it?
... Where the springboot-security-jwt /token endpoint implementation? to check it (or a kind of "health endpoint test")...
The primary configuration in the project springboot-security-jwt is in the WebSecurityConfig.java: (see https://github.com/svlada/springboot-security-jwt/blob/master/src/main/java/com/svlada/security/config/WebSecurityConfig.java).
In this class you will see a bean created of type AjaxLoginProcessingFilter configured with to intercept requests matching "/api/auth/login". This will process the login and generate the JWT tokens.
You can then follow to the next bean configured - JwtTokenAuthenticationProcessingFilter to see what it is intercepting and authenticating using the JWTToken provided on the api requests
refreshToken is a standard spring controller - see RefreshTokenEndpoint class (https://github.com/svlada/springboot-security-jwt/blob/master/src/main/java/com/svlada/security/endpoint/RefreshTokenEndpoint.java)
The author also provides a detailed explanation in the Blog.md under the etc folder - check it out! there are lots of useful links to get up to speed on using JWTs

Resources