use of javax.xml.ws.BindingProvider in project bamboobsc by billchen198318.
the class WsServiceUtils method getService.
public static Object getService(String wsClientBeanId, String wsdlAddress) throws Exception {
if (StringUtils.isBlank(wsClientBeanId)) {
throw new IllegalArgumentException("error, bean-Id is required!");
}
Object serviceObj = AppContext.getBean(wsClientBeanId);
if (!StringUtils.isBlank(wsdlAddress)) {
// 更改連線wsdl位置, 不使用原本xml設定檔中設定的連線wsdl位置
BindingProvider bindingProvider = (BindingProvider) serviceObj;
bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsdlAddress);
}
return serviceObj;
}
use of javax.xml.ws.BindingProvider in project camel by apache.
the class Client method invoke.
public String invoke() throws Exception {
// Service Qname as defined in the WSDL.
QName serviceName = new QName("http://apache.org/hello_world_soap_http", "SOAPService");
// Port QName as defined in the WSDL.
QName portName = new QName("http://apache.org/hello_world_soap_http", "SoapOverHttpRouter");
// Create a dynamic Service instance
Service service = Service.create(serviceName);
// Add a port to the Service
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
// Create a dispatch instance
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE);
// Use Dispatch as BindingProvider
BindingProvider bp = dispatch;
MessageFactory factory = ((SOAPBinding) bp.getBinding()).getMessageFactory();
// Create SOAPMessage Request
SOAPMessage request = factory.createMessage();
// Request Body
SOAPBody body = request.getSOAPBody();
// Compose the soap:Body payload
QName payloadName = new QName("http://apache.org/hello_world_soap_http/types", "greetMe", "ns1");
SOAPBodyElement payload = body.addBodyElement(payloadName);
SOAPElement message = payload.addChildElement("requestType");
message.addTextNode("Hello Camel!!");
System.out.println("Send out the request: Hello Camel!!");
// Invoke the endpoint synchronously
// Invoke endpoint operation and read response
SOAPMessage reply = dispatch.invoke(request);
// process the reply
body = reply.getSOAPBody();
QName responseName = new QName("http://apache.org/hello_world_soap_http/types", "greetMeResponse");
SOAPElement bodyElement = (SOAPElement) body.getChildElements(responseName).next();
String responseMessageText = bodyElement.getTextContent();
System.out.println("Get the response: " + responseMessageText);
return responseMessageText;
}
use of javax.xml.ws.BindingProvider in project camel by apache.
the class CxfMessageHeadersRelayTest method addOutOfBoundHeader.
protected static void addOutOfBoundHeader(HeaderTester proxy, boolean invalid) throws JAXBException {
InvocationHandler handler = Proxy.getInvocationHandler(proxy);
BindingProvider bp = null;
try {
if (handler instanceof BindingProvider) {
bp = (BindingProvider) handler;
Map<String, Object> requestContext = bp.getRequestContext();
requestContext.put(Header.HEADER_LIST, buildOutOfBandHeaderList(invalid));
}
} catch (JAXBException ex) {
throw ex;
}
}
use of javax.xml.ws.BindingProvider in project camel by apache.
the class CxfMessageHeadersRelayTest method validateReturnedOutOfBandHeader.
protected static void validateReturnedOutOfBandHeader(HeaderTester proxy, boolean expect) {
InvocationHandler handler = Proxy.getInvocationHandler(proxy);
BindingProvider bp = null;
if (!(handler instanceof BindingProvider)) {
fail("Unable to cast dynamic proxy InocationHandler to BindingProvider type");
}
bp = (BindingProvider) handler;
Map<String, Object> responseContext = bp.getResponseContext();
validateReturnedOutOfBandHeader(responseContext, expect);
}
use of javax.xml.ws.BindingProvider in project camel by apache.
the class CxfMessageHeadersRelayTest method testInoutOutOfBandHeaderCXFClientRelayWithHeaderInsertion.
@Test
public void testInoutOutOfBandHeaderCXFClientRelayWithHeaderInsertion() throws Exception {
HeaderService s = new HeaderService(getClass().getClassLoader().getResource("soap_header.wsdl"), HeaderService.SERVICE);
HeaderTester proxy = s.getSoapPortRelayWithInsertion();
((BindingProvider) proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + portE2 + "/CxfMessageHeadersRelayTest/HeaderService/");
addOutOfBoundHeader(proxy, false);
Me me = new Me();
me.setFirstName("john");
me.setLastName("Doh");
Me response = proxy.inoutOutOfBandHeader(me);
assertTrue("Expected the out of band header to propagate but it didn't", response.getFirstName().equals("pass"));
InvocationHandler handler = Proxy.getInvocationHandler(proxy);
BindingProvider bp = null;
if (!(handler instanceof BindingProvider)) {
fail("Unable to cast dynamic proxy InocationHandler to BindingProvider type");
}
bp = (BindingProvider) handler;
Map<String, Object> responseContext = bp.getResponseContext();
validateReturnedOutOfBandHeaderWithInsertion(responseContext, true);
}
Aggregations