Information other than WSDL using JAX-WS for SOAP? - java

I am using JAX-WS to export some SOAP Web Service Endpoints.
I know I can access the WSDL by appending ?WSDL to the web service endpoint. (Like http://localhost:8888/web_service/test?WSDL
Is there any other information I can get by appending things to the URL?

If you have a look at the generated WSDL (if you're using #WebService annotation) you can see that you can find the XSD with "?xsd=1".
I don't know how standard this is, though, and if there are cases where you could have different values than 1.

Related

Spring MVC calling existing third party SOAP Service with WSDL and Service Name

I am working on a Spring MVC project with Spring 4.3.2 (latest at this time).
We also use Spring Security 4.1.1 and Hibernate 5.01. This back-end project is a set of RESTful API's.
Within the business login in our "services" layer, we want to call several third party SOAP Web-Services. We actually DO have the WSDL files, and a service name from these outside SOAP web-services. We do have the URL, and this URL is the location of the WSDL file, we have the username password.
I suppose this could be a standard java question on how to call/consume SOAP web-services, but since we are in the Spring world, I figure we want out code to be "Spring-ified."
I'll keep looking on the net, but most of the examples I have seen require a WSDL file we do not have at this point.
Any help would be much appreciated. Thanks!
UPDATE:
I was looking at some old code we had with Seam, JBoss, and RichFaces. There are a few API calls from Jboss/J2EE which we are removing. It looks like we had a generic SOAP proxy which took a WSDL-URL string and a QName. It looks like this old code had a FormSubmit and a FormSubmitResponse which was a class for a JAXB conversion to these objects.
So, provided I have the WSDL in a URL, and a known method name to call. That should make my problem easier.
You can generate the Web Service Stubs with Maven or Gradle (depending on what you are using)
Take a look at this example:
https://spring.io/guides/gs/consuming-web-service/

Is the java source code generated from "wsimport <wsdl_url>" is actual soap web service code?

I have a wsdl url http://www.webservicex.net/geoipservice.asmx?WSDL
now if i generate a java source code by
wsimport -keep http://www.webservicex.net/geoipservice.asmx?WSDL
Is it going to generate actual soap web service code or just a interface which can call web service ?
I have seen some videos on youtube and as far as i think it cannot generate the actual java source code of soap web service. Please correct me if i am wrong.
so suppose if i want to make changes in soap web service(written in java), the changes in the generated file will not serve the purpose.
May be my question seems very basic to you, but i was looking at an application code and got this confusion , so please answer my query.
The wsimport tool is used to parse an existing Web Services
Description Language (WSDL) file and generate required files (JAX-WS
portable artifacts) for web service client to access the published web
services.
wsimport generates and compile the web service artifacts needed to connect to the service. This utility does not generate the actual web service.
I know that this is an old question , but for the record if you want to generate the actual WebService from an existing WSDL file you should use wsimport sibling which called wsgen

How to use WSDL

I'm working on a WSDL application. But actually I didn't understand what makes the "?wsdl" parameter and what will I do with the returned XML. For example:
https://adwords.google.com/api/adwords/cm/v201309/CampaignService?wsdl
This URL returns and XML string but what will I do with this?
I can convert schema files to java classes using jaxb (xjc) but I didn't understand correctly how to use this WSDL?
Thanks for your answers.
WSDL(Web Services Description Language) is just a contract in the form of xml defining the web services. It contains the details of input and output params of webservices. It is used between client and server to define the interface of communication. It is analogous to a method signature in a programming language. But as it is used between hetrogenous systems so xml is used to describe it.
WSDL is a XML file which contains description of a SOAP web service. WSDL file contains details regarding XML request structure, XML response structure, Web service endpoint details, Web service URL etc.WSDL file is the single most important file of a SOAP web service. The owner of a web service provides WSDL file to the client and by using the WSDL file a client interacts with the service. By using the WSDL file a client can generate client side stubs and java classes to contact with the server. Java since its release 7 supports APIs to generate client side code from a WSDL file. WSDL is created at the time of creating the web service.
When you have that URL containing the WSDL,simply use a tool like SOAPUI and generate a SOAP message and invoke web service. Web service can contain one more input elements so in that case you need to provide input element in the SOAP message.
To invoke a web service you just need a WSDL URL , you already have that. Just use a tool like SOAPUI.
WSDL is the file describing your webservices.
Meta Information about your methods, etc.
Any Web Client should understand and use WSDL files to generates all methods needed to communicate with a Web Server.

How do you intercept WSDL requests in CXF?

Backstory:
I have a WSDL that was created by the customer (non-negotiable) that mixes several web standards into a single service. This one soap service has four soap ports that refer to bindings in referenced (wsdl:import) WSDL files that import XSDs resulting in a dependency tree that is significantly complex.
Since this is done by imports, the top level WSDL isn't that big. WSDL2Java and wsimport choke on it, but I have a library of the schemas compiled into JAXB objects to work with. So I created a CXF service that has all of the required operations and I was able to test it with SoapUI (it imported the top level WSDL fine since it didn't have to make java classes).
Since all the soap ports point to the same address, and that service handles all the operations from the various ports, the client doesn't know that the server thinks all the operations belong to the same port.
Problem:
This breaks down when it comes to CXF generating the WSDL. It puts all the operations on one port with the same namespace. In the customer provided WSDL, the service, ports and bindings are not all in the same namespace. I have tried to supply the service with the WSDL using the #WebService(wsdlLocation="") annotation, but it tries to parse it and match it to the code (as it would in a sane world).
Question:
I would like to intercept/override the http://example.com/service?wsdl operation and return the customer provided wsdl. Is there a way to do this in CXF?
I ended up splitting the ports out into separate services, but I still needed a custom WSDL that had info for all the ports. The way to do this with CXF is to create an interceptor.
I followed the example of the CXF interceptor that regularly handles WSDL generation: http://grepcode.com/file/repo1.maven.org/maven2/org.apache.cxf/cxf-rt-frontend-simple/2.4.0/org/apache/cxf/frontend/WSDLGetInterceptor.java. I read in my custom WSDL and replace the placeholder hostname with the hostname that comes from the request URL.
You need to then add the custom interceptor when you make your service (I use spring for my configuration). More info on that at http://cxf.apache.org/docs/interceptors.html.

Get SOAP request and Response from the wsdl file from a client

I am using Apche Axis2 for a web service client. I know to get the output of a web service. But I want to get the soap Request and response from the wsdl file.
My wsdl is http://localhost:8080/getDetails?wsdl
It would be great if some can share their experiences.
Thanks in Advance.
If you want to use a software for that, use SoapUI.
If you want to do it from Java, you have these options.
Generate the classes for a SOAP Client using wsdl2java command.
There are many ways of doing this depends on the implementation you used.
Generate the classes for a SOAP Client using maven plugin, use this axistools-maven-plugin
After this search for a class having a name "...Locator" and "..PortType", use these classes.
OR,
Search for an Interface which has all the exposed methods and find a way to implement it.
Use SoapUI Tool , provide your WSDL path to this tool , it will load all operations from WSDL once if you click on perticular operation you can get sample SOAP request(XML payloads).

Categories

Resources