本文整理了Java中javax.xml.ws.Dispatch.invoke()
方法的一些代码示例,展示了Dispatch.invoke()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dispatch.invoke()
方法的具体详情如下:
包路径:javax.xml.ws.Dispatch
类名称:Dispatch
方法名:invoke
[英]Invoke a service operation synchronously. The client is responsible for ensuring that the msg object when marshalled is formed according to the requirements of the protocol binding in use.
[中]同步调用服务操作。客户机负责确保编组时的msg对象是根据使用的协议绑定的要求形成的。
代码示例来源:origin: stackoverflow.com
import javax.xml.bind.JAXBContext;
import javax.xml.namespace.QName;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
import javax.xml.ws.soap.SOAPBinding;
import blog.jaxws.provider.*;
public class Demo {
public static void main(String[] args) throws Exception {
QName serviceName = new QName("http://service.jaxws.blog/", "FindCustomerService");
Service service = Service.create(serviceName);
QName portQName = new QName("http://example.org", "SimplePort");
service.addPort(portQName, SOAPBinding.SOAP11HTTP_BINDING, "http://localhost:8080/Provider/FindCustomerService?wsdl");
JAXBContext jc = JAXBContext.newInstance(FindCustomerRequest.class, FindCustomerResponse.class);
Dispatch<Object> sourceDispatch = service.createDispatch(portQName, jc, Service.Mode.PAYLOAD);
FindCustomerRequest request = new FindCustomerRequest();
FindCustomerResponse response = (FindCustomerResponse) sourceDispatch.invoke(request);
System.out.println(response.getValue().getFirstName());
}
}
代码示例来源:origin: be.e_contract.mycarenet/mycarenet-ehealth-gen-ins
/**
* Invokes a method on the eHealth Generic Insurability web service using
* the low-level SOAP payload.
*
* @param request
* @return
*/
public String invoke(String request) {
Source responseSource = this.dispatch.invoke(new StreamSource(
new StringReader(request)));
return toString(responseSource);
}
代码示例来源:origin: be.e_contract.mycarenet/mycarenet-ehealth-ehealthbox
public Element invoke(Element request) {
Source responseSource = this.publicationDispatch.invoke(new DOMSource(
request));
Element responseElement = toElement(responseSource);
return responseElement;
}
代码示例来源:origin: be.e_contract.mycarenet/mycarenet-ehealth-ehealthbox
public String invoke(String request) {
Source responseSource = this.publicationDispatch
.invoke(new StreamSource(new StringReader(request)));
LOG.debug("response Source type: "
+ responseSource.getClass().getName());
return toString(responseSource);
}
代码示例来源:origin: be.e_contract.mycarenet/mycarenet-ehealth-gen-ins
/**
* Invokes a method on the eHealth Generic Insurability web service using
* the low-level SOAP payload.
*
* @param request
* @return
*/
public Element invoke(Element request) {
Source responseSource = this.dispatch.invoke(new DOMSource(request));
Element responseElement = toElement(responseSource);
return responseElement;
}
代码示例来源:origin: be.e_contract.mycarenet/mycarenet-ehealth-ehealthbox
/**
* Invokes a method on the eHealthBox consultation web service using the
* low-level SOAP payload.
*
* @param request
* @return
*/
public Element invoke(Element request) {
Source responseSource = this.consultationDispatch.invoke(new DOMSource(
request));
Element responseElement = toElement(responseSource);
return responseElement;
}
代码示例来源:origin: be.e_contract.mycarenet/mycarenet-ehealth-ehealthbox
/**
* Invokes a method on the eHealthBox consultation web service using the
* low-level SOAP payload.
*
* @param request
* @return
*/
public String invoke(String request) {
Source responseSource = this.consultationDispatch
.invoke(new StreamSource(new StringReader(request)));
LOG.debug("response Source type: "
+ responseSource.getClass().getName());
return toString(responseSource);
}
代码示例来源:origin: octo-online/reactive-audit
@Test(expected = NetworkReactiveAuditException.class)
public void invoke()
{
TestTools.strict.commit();
x.invoke(null);
}
代码示例来源:origin: octo-online/reactive-audit
@Test(expected = NetworkReactiveAuditException.class)
public void invoke()
{
TestTools.strict.commit();
x.invoke(null);
}
代码示例来源:origin: apache/cxf
@Test
public void testHeaderValidation() throws Exception {
URL wsdl = getClass().getResource("/wsdl/schema_validation.wsdl");
assertNotNull(wsdl);
SchemaValidationService service = new SchemaValidationService(wsdl, serviceName);
assertNotNull(service);
String smsg = "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Header>"
+ "<SomeHeader soap:mustUnderstand='1' xmlns='http://apache.org/schema_validation/types'>"
+ "<id>1111111111</id></SomeHeader>"
+ "</soap:Header><soap:Body><SomeRequestWithHeader xmlns='http://apache.org/schema_validation/types'>"
+ "<id>1111111111</id></SomeRequestWithHeader></soap:Body></soap:Envelope>";
Dispatch<Source> dsp = service.createDispatch(SchemaValidationService.SoapPort, Source.class, Mode.MESSAGE);
updateAddressPort(dsp, PORT);
dsp.invoke(new StreamSource(new StringReader(smsg)));
}
代码示例来源:origin: apache/cxf
@Test
public void testEchoProviderAsync() 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);
StreamSource request = new StreamSource(new ByteArrayInputStream(requestString.getBytes()));
StreamSource response = dispatcher.invoke(request);
assertEquals(requestString, StaxUtils.toString(response));
}
代码示例来源:origin: apache/cxf
@Test
public void testInvokeWithDataSourcMessageModeXMLBinding() throws Exception {
URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
assertNotNull(wsdl);
XMLService service = new XMLService();
assertNotNull(service);
Dispatch<DataSource> disp = service.createDispatch(portNameXML, DataSource.class, Mode.MESSAGE);
setAddress(disp, addNumbersAddress);
TestHandlerXMLBinding handler = new TestHandlerXMLBinding();
addHandlersProgrammatically(disp, handler);
URL is = getClass().getResource("/messages/XML_GreetMeDocLiteralReq.xml");
DataSource ds = new URLDataSource(is);
DataSource resp = disp.invoke(ds);
assertNotNull(resp);
}
代码示例来源:origin: apache/cxf
@Test
public void testInvokeWithDataSourcPayloadModeXMLBinding() throws Exception {
URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
assertNotNull(wsdl);
XMLService service = new XMLService();
assertNotNull(service);
Dispatch<DataSource> disp = service.createDispatch(portNameXML, DataSource.class, Mode.PAYLOAD);
setAddress(disp, addNumbersAddress);
TestHandlerXMLBinding handler = new TestHandlerXMLBinding();
addHandlersProgrammatically(disp, handler);
URL is = getClass().getResource("/messages/XML_GreetMeDocLiteralReq.xml");
DataSource ds = new URLDataSource(is);
DataSource resp = disp.invoke(ds);
assertNotNull(resp);
}
代码示例来源:origin: apache/cxf
@Test
public void testDiaptchWithWsaDisable() throws Exception {
QName port = new QName("http://apache.org/cxf/systest/ws/addr_feature/", "AddNumbersPort");
Dispatch<SOAPMessage> disptch = getService().createDispatch(port, SOAPMessage.class,
javax.xml.ws.Service.Mode.MESSAGE,
new AddressingFeature(false));
((BindingProvider)disptch).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://localhost:"
+ PORT + "/jaxws/add");
InputStream is = getClass().getResourceAsStream("resources/AddNumbersDispatchReq.xml");
SOAPMessage soapReqMsg = MessageFactory.newInstance().createMessage(null, is);
assertNotNull(soapReqMsg);
try {
disptch.invoke(soapReqMsg);
fail("The MAPcodec ate the SOAPFaultException");
} catch (javax.xml.ws.soap.SOAPFaultException e) {
//expected
}
}
代码示例来源:origin: apache/cxf
@Test
public void testInvokeWithDOMSourcMessageModeXMLBinding() throws Exception {
URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
assertNotNull(wsdl);
XMLService service = new XMLService();
assertNotNull(service);
Dispatch<DOMSource> disp = service.createDispatch(portNameXML, DOMSource.class, Mode.MESSAGE);
setAddress(disp, addNumbersAddress);
TestHandlerXMLBinding handler = new TestHandlerXMLBinding();
addHandlersProgrammatically(disp, handler);
InputStream is = getClass().getResourceAsStream("/messages/XML_GreetMeDocLiteralReq.xml");
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage soapReq = factory.createMessage(null, is);
DOMSource domReqMessage = new DOMSource(soapReq.getSOAPPart());
DOMSource response = disp.invoke(domReqMessage);
assertNotNull(response);
}
代码示例来源:origin: apache/cxf
@Test
public void testInvokeWithDOMSourcPayloadModeXMLBinding() throws Exception {
URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
assertNotNull(wsdl);
XMLService service = new XMLService();
assertNotNull(service);
Dispatch<DOMSource> disp = service.createDispatch(portNameXML, DOMSource.class, Mode.PAYLOAD);
setAddress(disp, addNumbersAddress);
TestHandlerXMLBinding handler = new TestHandlerXMLBinding();
addHandlersProgrammatically(disp, handler);
InputStream is = getClass().getResourceAsStream("/messages/XML_GreetMeDocLiteralReq.xml");
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage soapReq = factory.createMessage(null, is);
DOMSource domReqMessage = new DOMSource(soapReq.getSOAPPart());
DOMSource response = disp.invoke(domReqMessage);
assertNotNull(response);
}
代码示例来源:origin: apache/cxf
@Test
public void testInvokeWithDOMSourcPayloadMode() throws Exception {
URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
assertNotNull(wsdl);
AddNumbersService service = new AddNumbersService(wsdl, serviceName);
assertNotNull(service);
Dispatch<DOMSource> disp = service.createDispatch(portName, DOMSource.class, Mode.PAYLOAD);
setAddress(disp, addNumbersAddress);
TestHandler handler = new TestHandler();
TestSOAPHandler soapHandler = new TestSOAPHandler();
addHandlersProgrammatically(disp, handler, soapHandler);
InputStream is2 = this.getClass().getResourceAsStream("resources/GreetMeDocLiteralReqPayload.xml");
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage soapReq = factory.createMessage(null, is2);
DOMSource domReqMessage = new DOMSource(soapReq.getSOAPPart());
DOMSource response = disp.invoke(domReqMessage);
assertNotNull(response);
}
代码示例来源:origin: apache/cxf
@Test
public void testInvokeWithSOAPMessageMessageMode() throws Exception {
URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
assertNotNull(wsdl);
AddNumbersService service = new AddNumbersService(wsdl, serviceName);
assertNotNull(service);
Dispatch<SOAPMessage> disp = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
setAddress(disp, addNumbersAddress);
TestHandler handler = new TestHandler();
TestSOAPHandler soapHandler = new TestSOAPHandler();
addHandlersProgrammatically(disp, handler, soapHandler);
InputStream is2 = this.getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml");
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage soapReq = factory.createMessage(null, is2);
SOAPMessage response = disp.invoke(soapReq);
assertNotNull(response);
//response.writeTo(System.out);
}
代码示例来源:origin: apache/cxf
@Test
public void testInvokeWithJAXBPayloadModeXMLBinding() throws Exception {
URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
assertNotNull(wsdl);
XMLService service = new XMLService();
assertNotNull(service);
JAXBContext jc = JAXBContext.newInstance("org.apache.hello_world_xml_http.wrapped.types");
Dispatch<Object> disp = service.createDispatch(portNameXML, jc, Mode.PAYLOAD);
setAddress(disp, greeterAddress);
TestHandlerXMLBinding handler = new TestHandlerXMLBinding();
addHandlersProgrammatically(disp, handler);
org.apache.hello_world_xml_http.wrapped.types.GreetMe req =
new org.apache.hello_world_xml_http.wrapped.types.GreetMe();
req.setRequestType("tli");
Object response = disp.invoke(req);
assertNotNull(response);
org.apache.hello_world_xml_http.wrapped.types.GreetMeResponse value =
(org.apache.hello_world_xml_http.wrapped.types.GreetMeResponse)response;
assertEquals("Hello tli", value.getResponseType());
}
代码示例来源:origin: apache/cxf
@Test
public void testInvokeWithJAXBMessageModeXMLBinding() throws Exception {
URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
assertNotNull(wsdl);
XMLService service = new XMLService();
assertNotNull(service);
JAXBContext jc = JAXBContext.newInstance("org.apache.hello_world_xml_http.wrapped.types");
Dispatch<Object> disp = service.createDispatch(portNameXML, jc, Mode.MESSAGE);
setAddress(disp, greeterAddress);
TestHandlerXMLBinding handler = new TestHandlerXMLBinding();
addHandlersProgrammatically(disp, handler);
org.apache.hello_world_xml_http.wrapped.types.GreetMe req =
new org.apache.hello_world_xml_http.wrapped.types.GreetMe();
req.setRequestType("tli");
Object response = disp.invoke(req);
assertNotNull(response);
org.apache.hello_world_xml_http.wrapped.types.GreetMeResponse value =
(org.apache.hello_world_xml_http.wrapped.types.GreetMeResponse)response;
assertEquals("Hello tli", value.getResponseType());
}
内容来源于网络,如有侵权,请联系作者删除!