本文整理汇总了Java中javax.xml.ws.Dispatch.invokeOneWay方法的典型用法代码示例。如果您正苦于以下问题:Java Dispatch.invokeOneWay方法的具体用法?Java Dispatch.invokeOneWay怎么用?Java Dispatch.invokeOneWay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.ws.Dispatch
的用法示例。
在下文中一共展示了Dispatch.invokeOneWay方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testWebService
import javax.xml.ws.Dispatch; //导入方法依赖的package包/类
@Test
@RunAsClient
public void testWebService() throws Exception
{
URL wsdlURL = new URL(baseURL + "/TestService?wsdl");
QName serviceName = new QName(targetNS, "PingEndpointService");
QName portName = new QName(targetNS, "PingEndpointPort");
Service service = Service.create(wsdlURL, serviceName);
Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
String payload = "<ns1:ping xmlns:ns1='http://oneway.samples.jaxws.ws.test.jboss.org/'/>";
dispatch.invokeOneWay(new StreamSource(new StringReader(payload)));
//sleep 5 sec as invokeOneWay is supposed to be non-blocking subject to the capabilities of the underlying protocol
Thread.sleep(5000);
payload = "<ns1:feedback xmlns:ns1='http://oneway.samples.jaxws.ws.test.jboss.org/'/>";
Source retObj = dispatch.invoke(new StreamSource(new StringReader(payload)));
Element docElement = DOMUtils.sourceToElement(retObj);
Element retElement = DOMUtils.getFirstChildElement(docElement);
DOMWriter.printNode(retElement, false);
assertEquals("return", retElement.getNodeName());
assertEquals("result: ok", retElement.getTextContent());
}