First I make Service Endpoint Interface like below,
package com.aaa.ws;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
//import javax.xml.ws.soap.Addressing;
import org.jboss.ws.api.annotation.PolicySets;
@WebService
//@Addressing(enabled=true, required=false)
@PolicySets({"WS-RM_Policy_spec_example", "WS-SP-EX223_WSS11_Anonymous_X509_Sign_Encrypt", "WS-Addressing"})
public interface IHelloWorld {
@WebMethod
@WebResult
public String sayHello(@WebParam String name);
}
,and deploy it on eclipse IDE
https://community.jboss.org/servlet/JiveServlet/downloadImage/2-833521-21326/450-428/policy_1.jpg
https://community.jboss.org/servlet/JiveServlet/downloadImage/2-833521-21327/450-557/policy_2.jpg
Deployment is successful. The wsdl is generated successfully. The console shows the messages :
19:49:11,763 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "WSHelloWorldEAR.ear" (runtime-name: "WSHelloWorldEAR.ear")
19:49:11,904 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of "null" (runtime-name: "WSHelloWorld.war")
19:49:13,635 INFO [org.jboss.ws.cxf.metadata] (MSC service thread 1-1) JBWS024061: Adding service endpoint metadata: id=HelloWorld
address=http://localhost:8080/WSHelloWorld/HelloWorld
implementor=com.aaa.ws.HelloWorld
serviceName={http://ws.aaa.com/}HelloWorldService
portName={http://ws.aaa.com/}HelloWorldPort
annotationWsdlLocation=null
wsdlLocationOverride=null
mtomEnabled=false
19:49:13,886 INFO [org.apache.cxf.service.factory.ReflectionServiceFactoryBean] (MSC service thread 1-1) Creating Service {http://ws.aaa.com/}HelloWorldService from class com.aaa.ws.IHelloWorld
19:49:14,369 INFO [org.jboss.ws.cxf] (MSC service thread 1-1) JBWS024092: Adding BINDING policy attachment with id='WS-RM_Policy_spec_example_binding_policy' to honor requirement from interface com.aaa.ws.IHelloWorld.
19:49:14,369 INFO [org.jboss.ws.cxf] (MSC service thread 1-1) JBWS024092: Adding BINDING policy attachment with id='WS-SP-EX223_binding_policy' to honor requirement from interface com.aaa.ws.IHelloWorld.
19:49:14,369 INFO [org.jboss.ws.cxf] (MSC service thread 1-1) JBWS024092: Adding BINDING policy attachment with id='WS-Addressing_binding_policy' to honor requirement from interface com.aaa.ws.IHelloWorld.
19:49:14,369 INFO [org.jboss.ws.cxf] (MSC service thread 1-1) JBWS024092: Adding BINDING_OPERATION_INPUT policy attachment with id='WS-SP-EX223_Binding_Operation_Input_Policy' to honor requirement from interface com.aaa.ws.IHelloWorld.
19:49:14,369 INFO [org.jboss.ws.cxf] (MSC service thread 1-1) JBWS024092: Adding BINDING_OPERATION_OUTPUT policy attachment with id='WS-SP-EX223_Binding_Operation_Output_Policy' to honor requirement from interface com.aaa.ws.IHelloWorld.
19:49:14,697 INFO [org.apache.cxf.endpoint.ServerImpl] (MSC service thread 1-1) Setting the server's publish address to be http://localhost:8080/WSHelloWorld/HelloWorld
19:49:14,823 INFO [org.jboss.ws.cxf.deployment] (MSC service thread 1-1) JBWS024074: WSDL published to: file:/C:/wildfly-8.0.0.Alpha4/standalone/data/wsdl/WSHelloWorldEAR.ear/WSHelloWorld.war/HelloWorldService.wsdl
19:49:14,870 INFO [org.jboss.as.webservices] (MSC service thread 1-3) JBAS015539: Starting service jboss.ws.endpoint."WSHelloWorldEAR.ear"."WSHelloWorld.war".HelloWorld
19:49:15,197 INFO [org.wildfly.extension.undertow] (MSC service thread 1-8) JBAS018210: Register web context: /WSHelloWorld
19:49:15,291 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS018559: Deployed "WSHelloWorldEAR.ear" (runtime-name : "WSHelloWorldEAR.ear")
But the problem is generating web service client codes from the wsdl which contains WS-Policy. I try to generate the client codes with Web Service Client Wizard of eclipse ide.
https://community.jboss.org/servlet/JiveServlet/downloadImage/2-833521-21328/450-428/policy_3.jpg
https://community.jboss.org/servlet/JiveServlet/downloadImage/2-833521-21329/450-409/policy_4.jpg
https://community.jboss.org/servlet/JiveServlet/downloadImage/2-833521-21330/450-473/policy_5.jpg
The client codes from the Web Service Client Wizard seems not to be applied by WS-Policy annotation.
The below client code throws many types of exceptions.
HelloWorldService service = new HelloWorldService();
IHelloWorld port = service.getHelloWorldPort();
out.println(port.sayHello("Joseph"));
Is there any option which make the WS client wizard generate correct client codes with WS-Policy?
I need your help!