OW2 EasyWSDL WSDL manipulation library has just been released. This release fix many bugs and introduces some new tooling such as java2wsdl (create WSDL from Java interfaces) and xsd2xml (create XML from XSD definition).
EasyWSDL is easy since you can manipulate both WSDL 1.1 and WSDL 2.0 with the same object model.
// Read a WSDL 1.1 or 2.0
WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
Description desc = reader.readWSDL(new URI("http://file/path/document.wsdl"));
// Write a WSDL 1.1 or 2.0 (depend of desc version)
Document doc = WSDLFactory.newInstance().newWSDLWriter().getDocument(desc);
// Create a WSDL 1.1 or 2.0
Description desc11 = WSDLFactory.newInstance().newDescription(WSDLVersionConstants.WSDL11);
Description desc20 = WSDLFactory.newInstance().newDescription(WSDLVersionConstants.WSDL20);
Once the Description object is loaded from the WSDL document, you can maniulate all parts of the service description. Let’s look at endpoints :
// Endpoints take place in services.
// Select a service
Service service = desc.getServices().get(0);
// List endpoints
List endpoints = service.getEndpoints();
// Read specific endpoint
Endpoint specificEndpoint = service.getEndpoint("endpointName");
// Add endpoint to service
service.addEndpoint(specificEndpoint);
// Remove a specific enpoint
service.removeEndpoint("endpointName");
// Create endpoint
Endpoint createdEndpoint = service.createEndpoint();
service.addEndpoint(createdEndpoint);
Easy!
WebService, soa
easywsdl, release, soa, WebService, wsdl
This is quite the same thing than the previous post where I introduced how to expose JAXWS service in PEtALS ESB with Maven. This time, let’s proxify a Web service in PEtALS with Maven.
Here is the Maven descriptor snippet :
<build>
<plugins>
<plugin>
<groupId>org.ow2.petals</groupId>
<artifactId>maven-petals-wsproxy</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<id>generate-jbi</id>
<phase>package</phase>
<configuration>
<wsdl>
http://localhost:8080/Service?wsdl
</wsdl>
</configuration>
<goals>
<goal>wsproxy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
This will generate a JBI Service Assembly that you can then deploy intoo PEtALS to proxify the service defined in http://localhost:8080/Service?wsdl
You can give it a try, the snapshot version is available on the OW2 Maven repository…
PEtALS
maven, PEtALS, WebService
Just a quick note to show that the client factory choice is important with Apache CXF 2.1.4.
The service interface definition :
package org.ow2.petals.usecase.soapaddressing.server;
import javax.jws.WebMethod;
import javax.jws.WebService;
/**
* @author chamerling - eBM WebSourcing
*
*/
@WebService
public interface AddressingService {
/**
* Get the local information
*
* @return
*/
@WebMethod
String getInfo();
}
The client with the bad client factory :
package org.ow2.petals.usecase.soapaddressing.client;
import org.apache.cxf.frontend.ClientProxyFactoryBean;
import org.ow2.petals.usecase.soapaddressing.server.AddressingService;
/**
* @author chamerling - eBM WebSourcing
*
*/
public class BadFactory {
/**
* @param args
*/
public static void main(String[] args) {
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
factory.setServiceClass(AddressingService.class);
factory.setAddress("http://localhost:8084/petals/services/Service01");
AddressingService client = (AddressingService) factory.create();
String info = client.getInfo();
System.out.println(info);
}
}
With that client code, the Web Service is really invoked, but the result of the getInfo operation is null. So, let’s do it with the right client factory…
The client with the good client factory :
package org.ow2.petals.usecase.soapaddressing.client;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.ow2.petals.usecase.soapaddressing.server.AddressingService;
/**
* @author chamerling - eBM WebSourcing
*
*/
public class GoodFactory {
/**
* @param args
*/
public static void main(String[] args) {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(AddressingService.class);
factory.setAddress("http://localhost:8084/petals/services/Service01");
AddressingService client = (AddressingService) factory.create();
String info = client.getInfo();
System.out.println(info);
}
}
This time the result is not null and is really the one expected…
WebService
cxf, java, WebService