本文整理了Java中javax.xml.ws.Dispatch.getRequestContext()
方法的一些代码示例,展示了Dispatch.getRequestContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dispatch.getRequestContext()
方法的具体详情如下:
包路径:javax.xml.ws.Dispatch
类名称:Dispatch
方法名:getRequestContext
暂无
代码示例来源:origin: org.picketlink/picketlink-trust-jbossws
public Map<String, Object> getRequestContext()
{
return parent.getRequestContext();
}
代码示例来源:origin: org.picketlink.distribution/picketlink-jbas7
public Map<String, Object> getRequestContext() {
return parent.getRequestContext();
}
代码示例来源:origin: org.picketlink.distribution/picketlink-jbas5
public Map<String, Object> getRequestContext() {
return parent.getRequestContext();
}
代码示例来源:origin: Talend/tesb-rt-se
public static void setCallbackEndpoint(
final Dispatch<?> dispatch, final Object callbackEndpoint) {
dispatch.getRequestContext().put(
RequestCallbackFeature.CALLBACK_ENDPOINT_PROPERTY_NAME, callbackEndpoint);
}
代码示例来源:origin: com.carecon.fabric3/fabric3-binding-ws
private void setSOAPAction(Dispatch<Source> dispatch) {
Map<String, Object> context = dispatch.getRequestContext();
context.put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
context.put(BindingProvider.SOAPACTION_URI_PROPERTY, "");
}
代码示例来源:origin: org.fabric3/fabric3-binding-ws-metro
private void setSOAPAction(Dispatch<Source> dispatch) {
Map<String, Object> context = dispatch.getRequestContext();
context.put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
context.put(BindingProvider.SOAPACTION_URI_PROPERTY, "");
}
代码示例来源:origin: Talend/tesb-rt-se
public static void enforceOperation(
final QName operationName, final String soapAction, final Dispatch<?> dispatch) {
enforceOperation(operationName, soapAction, dispatch.getRequestContext());
}
代码示例来源:origin: Talend/tesb-rt-se
public static void enforceOperation(final QName operationName, final Dispatch<?> dispatch) {
enforceOperation(operationName, null, dispatch.getRequestContext());
}
代码示例来源:origin: be.e_contract.mycarenet/mycarenet-ehealth-saml-sts
/**
* Main constructor.
*
* @param location
* the URL of the eHealth STS web service.
*/
public EHealthSTSClient(String location) {
EHealthSamlStsService service = EHealthSamlStsServiceFactory.newInstance();
QName portQName = new QName("urn:be:ehealth:saml:sts:1.0", "EHealthSamlStsPort");
this.dispatch = service.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD);
this.dispatch.getRequestContext().put(Dispatch.ENDPOINT_ADDRESS_PROPERTY, location);
Binding binding = dispatch.getBinding();
@SuppressWarnings("rawtypes")
List<Handler> handlerChain = binding.getHandlerChain();
this.wsSecuritySOAPHandler = new WSSecuritySOAPHandler();
handlerChain.add(this.wsSecuritySOAPHandler);
handlerChain.add(new LoggingHandler());
binding.setHandlerChain(handlerChain);
}
代码示例来源:origin: apache/cxf
private synchronized Dispatch<Object> getDispatchInternal(boolean addSeq, String action) {
if (dispatch == null) {
AddressingFeature f = new AddressingFeature(true, true);
dispatch = getService().createDispatch(version.getServiceName(), getJAXBContext(), Service.Mode.PAYLOAD, f);
dispatch.getRequestContext().put("thread.local.request.context", Boolean.TRUE);
version.addVersionTransformer(dispatch);
}
addAddressing(dispatch, false, action);
return dispatch;
}
private void addAddressing(BindingProvider p, boolean addSeq, String action) {
代码示例来源:origin: org.apache.cxf.services.ws-discovery/cxf-services-ws-discovery-api
private synchronized Dispatch<Object> getDispatchInternal(boolean addSeq, String action) {
if (dispatch == null) {
AddressingFeature f = new AddressingFeature(true, true);
dispatch = getService().createDispatch(version.getServiceName(), getJAXBContext(), Service.Mode.PAYLOAD, f);
dispatch.getRequestContext().put("thread.local.request.context", Boolean.TRUE);
version.addVersionTransformer(dispatch);
}
addAddressing(dispatch, false, action);
return dispatch;
}
private void addAddressing(BindingProvider p, boolean addSeq, String action) {
代码示例来源:origin: apache/cxf
@Test
public void testDispatchActionMissmatch() throws Exception {
String req = "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ "<S:Body><addNumbers3 xmlns=\"http://apache.org/cxf/systest/ws/addr_feature/\">"
+ "<number1>1</number1><number2>2</number2></addNumbers3>"
+ "</S:Body></S:Envelope>";
//String base = "http://apache.org/cxf/systest/ws/addr_feature/AddNumbersPortType/";
String expectedOut = "http://bad.action";
URL wsdl = getClass().getResource("/wsdl_systest_wsspec/add_numbers.wsdl");
assertNotNull("WSDL is null", wsdl);
AddNumbersService service = new AddNumbersService(wsdl, serviceName);
Dispatch<Source> disp = service.createDispatch(AddNumbersService.AddNumbersPort,
Source.class, Mode.MESSAGE);
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://localhost:" + PORT + "/jaxws/add");
//manually set the action
disp.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,
expectedOut);
disp.getRequestContext().put(ContextUtils.ACTION,
expectedOut + "/wsaAction");
try {
disp.invoke(new StreamSource(new StringReader(req)));
fail("no exception");
} catch (SOAPFaultException f) {
//expected
}
}
代码示例来源:origin: apache/cxf
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://localhost:"
+ greeterPort
+ "/SOAPDispatchService/SoapDispatchPort");
disp.getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
SAXSource saxSourceResp = disp.invoke(saxSourceReq);
assertNotNull(saxSourceResp);
代码示例来源:origin: apache/cxf
@Test
public void testDOMSourcePAYLOAD() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world_xml_wrapped.wsdl");
assertNotNull(wsdl);
XMLService service = new XMLService(wsdl, SERVICE_NAME);
assertNotNull(service);
InputStream is = getClass().getResourceAsStream("/messages/XML_GreetMeDocLiteralReq.xml");
Document doc = StaxUtils.read(is);
DOMSource reqMsg = new DOMSource(doc);
assertNotNull(reqMsg);
Dispatch<DOMSource> disp = service.createDispatch(PORT_NAME, DOMSource.class,
Service.Mode.PAYLOAD);
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://localhost:"
+ port
+ "/XMLService/XMLDispatchPort");
DOMSource result = disp.invoke(reqMsg);
assertNotNull(result);
Node respDoc = result.getNode();
assertEquals("greetMeResponse", respDoc.getFirstChild().getLocalName());
assertEquals("Hello tli", respDoc.getFirstChild().getTextContent());
}
}
代码示例来源:origin: apache/cxf
@Test
public void testDuplicateHeaders() throws Exception {
URL wsdl = getClass().getResource("/wsdl_systest_wsspec/add_numbers.wsdl");
assertNotNull("WSDL is null", wsdl);
AddNumbersService service = new AddNumbersService(wsdl, serviceName);
QName portName = new QName("http://apache.org/cxf/systest/ws/addr_feature/", "AddNumbersPort");
Dispatch<SOAPMessage> disp = service.createDispatch(portName, SOAPMessage.class,
Service.Mode.MESSAGE,
new AddressingFeature(false, false));
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://localhost:" + PORT + "/jaxws/add");
InputStream msgIns = getClass().getResourceAsStream("./duplicate-wsa-header-msg.xml");
String msg = new String(IOUtils.readBytesFromStream(msgIns));
msg = msg.replaceAll("$PORT", PORT);
ByteArrayInputStream bout = new ByteArrayInputStream(msg.getBytes());
SOAPMessage soapReqMsg = MessageFactory.newInstance().createMessage(null, bout);
assertNotNull(soapReqMsg);
try {
disp.invoke(soapReqMsg);
fail("SOAPFaultFxception is expected");
} catch (SOAPFaultException ex) {
assertTrue("WSA header exception is expected",
ex.getMessage().indexOf("A header representing a Message Addressing") > -1);
}
}
代码示例来源:origin: apache/cxf
@Test
public void testStAXSourcePAYLOAD() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
Service service = Service.create(wsdl, SERVICE_NAME);
assertNotNull(service);
Dispatch<StAXSource> disp = service.createDispatch(PORT_NAME, StAXSource.class, Service.Mode.PAYLOAD);
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://localhost:"
+ greeterPort
+ "/SOAPDispatchService/SoapDispatchPort");
QName opQName = new QName("http://apache.org/hello_world_soap_http", "greetMe");
disp.getRequestContext().put(MessageContext.WSDL_OPERATION, opQName);
// Test request-response
InputStream is = getClass().getResourceAsStream("resources/GreetMeDocLiteralSOAPBodyReq.xml");
StAXSource staxSourceReq = new StAXSource(StaxUtils.createXMLStreamReader(is));
assertNotNull(staxSourceReq);
Source resp = disp.invoke(staxSourceReq);
assertNotNull(resp);
assertTrue(resp instanceof StAXSource);
String expected = "Hello TestSOAPInputMessage";
String actual = StaxUtils.toString(StaxUtils.read(resp));
assertTrue("Expected: " + expected, actual.contains(expected));
}
代码示例来源:origin: apache/cxf
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://localhost:"
+ greeterPort
代码示例来源:origin: apache/cxf
@Test
public void testEchoProviderAsyncDecoupledEndpoints() throws Exception {
String requestString = "<echo/>";
Service service = Service.create(serviceName);
service.addPort(fakePortName, javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING,
"http://localhost:" + PORT + "/SoapContext/AsyncEchoProvider");
Dispatch<StreamSource> dispatcher = service.createDispatch(fakePortName,
StreamSource.class,
Service.Mode.PAYLOAD,
new LoggingFeature());
Client client = ((DispatchImpl<StreamSource>)dispatcher).getClient();
WSAddressingFeature wsAddressingFeature = new WSAddressingFeature();
wsAddressingFeature.initialize(client, client.getBus());
dispatcher.getRequestContext().put("org.apache.cxf.ws.addressing.replyto",
"http://localhost:" + CLIENT_PORT
+ "/SoapContext/AsyncEchoClient");
StreamSource request = new StreamSource(new ByteArrayInputStream(requestString.getBytes()));
StreamSource response = dispatcher.invoke(request);
assertEquals(requestString, StaxUtils.toString(response));
}
}
代码示例来源:origin: apache/cxf
@Test
public void testSOAPMessageWithMalformedResponse() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, SERVICE_NAME);
assertNotNull(service);
Dispatch<SOAPMessage> disp = service
.createDispatch(PORT_NAME, SOAPMessage.class, Service.Mode.MESSAGE);
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://localhost:"
+ greeterPort
+ "/SOAPDispatchService/SoapDispatchPort");
// Test async callback
InputStream is3 = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq3.xml");
SOAPMessage soapReqMsg3 = MessageFactory.newInstance().createMessage(null, is3);
assertNotNull(soapReqMsg3);
TestSOAPMessageHandler tsmh = new TestSOAPMessageHandler();
Future<?> f = disp.invokeAsync(soapReqMsg3, tsmh);
assertNotNull(f);
waitForFuture(f);
assertEquals("AsyncHandler shouldn't get invoked more than once", asyncHandlerInvokedCount, 1);
}
代码示例来源:origin: apache/cxf
private static Dispatch<Source> createUsernameTokenDispatcher(boolean decoupled, String port) {
final Service service = Service.create(
GREETER_SERVICE_QNAME
);
service.addPort(
USERNAME_TOKEN_PORT_QNAME,
decoupled ? SOAPBinding.SOAP11HTTP_BINDING : HTTPBinding.HTTP_BINDING,
"http://localhost:" + port + "/GreeterService/UsernameTokenPort"
);
final Dispatch<Source> dispatcher = service.createDispatch(
USERNAME_TOKEN_PORT_QNAME,
Source.class,
Service.Mode.MESSAGE,
new AddressingFeature(decoupled, decoupled)
);
final java.util.Map<String, Object> requestContext =
dispatcher.getRequestContext();
requestContext.put(
MessageContext.HTTP_REQUEST_METHOD,
"POST"
);
if (decoupled) {
HTTPConduit cond = (HTTPConduit)((DispatchImpl<?>)dispatcher).getClient().getConduit();
cond.getClient().setDecoupledEndpoint("http://localhost:" + DEC_PORT + "/decoupled");
}
return dispatcher;
}
内容来源于网络,如有侵权,请联系作者删除!