JAX-WS Invoking a webservice using Implementation specific API such as CXF - java

Is it possible to invoke a web service in Java without using the JAX-WS API but a specific runtime implementation API such as CXF specific API?
I have Metro on my classpath an its causing issues when I use the JAX-WS API so I want to specify the exact JAX-WS API implementation to use dynamically when invoking the service
Thank u

Most likely, all the JAX-WS implementations have some sort of proprietary API that can be used to create services that would use their specific implementation and bypass the JAX-WS provider discovery mechanisms. In most cases, the discovered Providers are likely a wrapper onto those API's.
For CXF on the client side, that would be the JaxWsProxyFactoryBean:
http://cxf.apache.org/javadoc/latest/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.html
which can be used to create the Proxy objects from the JAX-WS generated interfaces.

You may build your request in plain XML and do SOAP request. To build XML structure, you may use SoapUI, where you can import WSDL which gives you xml input structure. Copy that in to java class,append the request params where ever necessary and fire the request. You don't require any Jax-WS API. Only the problem with this aproach is you need to write XML parser for inputs and outputs
[update] different solution
I use Java API to use framework features, but need to create client jars for given service and add to class path.
URL wsdlURL = new URL("http://localhost/myweb/services/xyz_services?wsdl");
QName SERVICE_NAME = new QName("http://service.sa.com/","portname");
Service service = Service.create(wsdlURL, SERVICE_NAME);
TestService client = service.getPort(TestService.class);
client.execute();
Provided your service looks like below
package com.sa.service;
Inteface TestService{
public void execute();
}
You can create client class using wsimport(Java tool) from command line and then jar them and add to classpath

Related

How to generete the Interface (SEI, Service Endpoint Interface) with jaxb2-maven-plugin 2.3.1

I am using the api jaxb2-maven-plugin 2.3.1 to create the class from a WSDL file in a web service SOAP (I am building a server). It work very fine, however I have seen that many people use other plugins to generate the interfaces, of this way the developer in the server only implements the interface and defines the bussines logical in the web service.
Someone knows how can I create the interfaces with the same plugin (jaxb2-maven-plugin 2.3.1). I do not know if that interfaces are only defined in the side of the client. It may be that's why I have not found anything regarding this api.
I am seaching how to do the SEI (Service EndPoint Interface) from jaxb2-maven-plugin. In the link say:
The best practice is to have an interface (SEI) that declares the web
service operations as its methods, and an implementation (SIB), which
defines the methods declared in the interface.
Regards.
You need to use the wsimport goal from the JAX-WS Maven Plugin instead of the JAXB plugin.
When generating a server you can temporarily set the genJWS to true in order to generate server implementation stubs.

How to use javax.xml.ws without interface of soap webService

I want to use a SOAP webservice with below URL:
http://ws.armaghan.net:8080/ws-relay/MessageRelayService?wsdl
According to post at How to do a call through a javax.xml.ws.Service I developed below code:
URL url= new URL("http://ws.armaghan.net:8080/ws-relay/MessageRelayService?wsdl");
QName qname= new QName("http://webservice.smsrelay.armaghan.net/","MessageRelayService");
Service service = Service.create(url, qname);
but at next step I do not now how to use service.getPort(Claas arg0) because I have not the interface of my SOAP web service. The only thing I have is the above URL.
By the way my question is that how can I use the web-service?
Thanks,
First you need to generate the client for the Web service through WSIMPORT or similar tool.
after that the generated client artifacts should be integrated with your client side code to call web service operations. you can refer following blog post that has the clear steps one by one.
http://chathurangat.blogspot.com/2013/09/how-to-generate-jax-ws-client-and.html
You should use a tool for generating the interfaces and the client. I usually save the wsdl file to my java project and use the ide to generate source code from the wsdl file.
Then you can choose your preferred framework. Axis, cxf, ws or what you want.
You can also use commandline tools like for example this
http://www.mkyong.com/webservices/jax-ws/jax-ws-wsimport-tool-example/

How to call a webservice with GET?

I have experiences in creating clients to a SOAP Webservice using JAX-WS. Therefore I'd mainly create a #WebService class with #WebMethod methods that take #WebParam params and return a #WebResult.
Mostly I start using CXFto auto-generate the Java classes from theWSDL`.
But what if the webservice is a GET service instead of a SOAP, like http://www.cleartrip.com/places/hotels/info/41748.
I can use a XSD accordingly to auto-generate my Java classes to JAXB as well.
But how do I then call that GET-Service? Which framework will assist me here? Is it also possible with JAX-WS?
You are confused because this is a restfull service and not a SOAP web service, java has an API for accessing restful services easily, see 'https://jersey.java.net/documentation/latest/getting-started.html' for more info.
What you call a GET service looks like a RESTful service. Take a look at JAX-RS 2.0 and the new client API.

How To Use WSDL Url

I wrote a java web service on Netbeans 6.9.1 and deployed on GlassFish 3.0.1
I have a wsdl url like this "http://localhost:8080/web2/service2Service?wsdl".
How can I use this url to access this web service from another java application.
Thanks
You need to generate some Java that represents the client's view of the Web Service and then invoke that Java. Here's an article which explains some of the detail.
Generating client from WSDL in Eclipse
The general idea is that you generate some Java classes from the WSDL. Those classes act as a proxy for the service you want to call. Your java invokes methods on the proxy objects, the generated code creates the appropriate SOAP messages, sends the HTTP request, interprets the response and your code just sees a Java result.
I just use the tooling built into Eclipse, but you will also find other suitable generators, for example in Apache's Axis
1º U must save the content in a "myWebServices.wsdl" file
2º Run your Wsdl converter, all compilers have one of this, normally the name is WDSL.EXE
This process will create a new file with NameSpace or Package with the definitions of webservices built in.
3º Then imports this package or built a library.
Develop web service Client in second application.
You can use Netbeans to create web service client by giving your wsdl url
The document at this url is the actual wsdl (a description of the actual webservice, written in WebService Definfition Language).
The description includes information about the services url, the protocol(s), the method names and and data objects. Your application will use that information to call the remote methods of that service.
The protocol may or may not be SOAP, and without knowing the webservice details, it's quite impossible to recommend a toolset or methodology to use the webservice, there is no general approach. In most cases we see SOAP, for those services I recomment soapUI as a general tool to use and test SOAP based webservices and apache axis to implement java based service consumers.

WSE 3.0 + X509 + java

Actually I have to work with a web service written in .NET with WSE 3.0 and digital signature and encryption of soap messages. I have to make a java client in order to consume the .net webservice.
I have the wsdl file, a CA.cer file, a certoencrypt.cer file from the provider and I would like to know where to start in order to make the java client so it can consume the web service.
Any help would be appreciated.
I don't know anything about wse 3.0, but that should have no limitation on creating a client to call the web-service from java. Generally, you should start by creating web-service proxy classes using something like JAX-WS RI (I'd recommend this since its packaged with JDK 1.6) or Axis2. Another useful tool for web-services development is SOAP UI.
From within soap ui, you can generate the above mentioned proxy classes using a variety of web service frameworks including the 2 mentioned above. once you have those classes generated, your going to want to reference them from your project and use them to make your web-service calls. there are examples of how to do this all over the internet, and the implementation details will depend on the framework you choose to use.

Categories