本文整理汇总了Java中javax.xml.ws.Dispatch.invoke方法的典型用法代码示例。如果您正苦于以下问题:Java Dispatch.invoke方法的具体用法?Java Dispatch.invoke怎么用?Java Dispatch.invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.ws.Dispatch
的用法示例。
在下文中一共展示了Dispatch.invoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEmptyCalendar
import javax.xml.ws.Dispatch; //导入方法依赖的package包/类
@Test
@RunAsClient
public void testEmptyCalendar() throws Exception {
URL wsdlURL = new URL(baseURL + "/EndpointService?wsdl");
QName qname = new QName("http://org.jboss.ws/jaxws/calendar", "EndpointService");
Service service = Service.create(wsdlURL, qname);
Dispatch<SOAPMessage> dispatch = service.createDispatch(new QName("http://org.jboss.ws/jaxws/calendar", "EndpointPort"), SOAPMessage.class, Mode.MESSAGE);
String reqEnv = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><ns2:echoCalendar xmlns:ns2=\"http://org.jboss.ws/jaxws/calendar\"><arg0/></ns2:echoCalendar></soap:Body></soap:Envelope>";
SOAPMessage reqMsg = MessageFactory.newInstance().createMessage(null, new ByteArrayInputStream(reqEnv.getBytes()));
SOAPMessage resMsg = dispatch.invoke(reqMsg);
assertNotNull(resMsg);
//TODO improve checks
}
示例2: testProviderDispatch
import javax.xml.ws.Dispatch; //导入方法依赖的package包/类
@Test
@RunAsClient
public void testProviderDispatch() throws Exception
{
String targetNS = "http://ws.com/";
QName serviceName = new QName(targetNS, "Provider");
QName portName = new QName(targetNS, "ProviderPort");
Service service = Service.create(serviceName);
service.addPort(portName, HTTPBinding.HTTP_BINDING, baseURL.toString());
Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
Source resPayload = dispatch.invoke(new DOMSource(DOMUtils.parse("<ns2:input xmlns:ns2='http://ws.com/'><arg0>hello</arg0></ns2:input>")));
Element docElement = DOMUtils.sourceToElement(resPayload);
Element response = ((Element)DOMUtils.getChildElements(docElement, "return").next());
assertEquals("hello", response.getTextContent());
}
示例3: testProviderDispatch
import javax.xml.ws.Dispatch; //导入方法依赖的package包/类
@Test
@RunAsClient
public void testProviderDispatch() throws Exception
{
Dispatch<SOAPMessage> dispatch = createDispatch("ProviderEndpoint");
SOAPMessage reqMsg = getRequestMessage();
SOAPMessage resMsg = dispatch.invoke(reqMsg);
SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();
SOAPHeader soapHeader = resEnv.getHeader();
if (soapHeader != null)
soapHeader.detachNode();
assertEquals(DOMUtils.parse(msgString), resEnv);
}
示例4: testWebService
import javax.xml.ws.Dispatch; //导入方法依赖的package包/类
@Test
@RunAsClient
public void testWebService() throws Exception
{
URL wsdlURL = new URL(baseURL + "?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);
dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
dispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "uri:placeBuyOrder");
String payload = "<ns1:ping xmlns:ns1='" + targetNS + "'/>";
Source retObj = dispatch.invoke(new StreamSource(new StringReader(payload)));
Element docElement = DOMUtils.sourceToElement(retObj);
Element retElement = DOMUtils.getFirstChildElement(docElement);
assertEquals("return", retElement.getLocalName());
assertEquals("\"uri:placeBuyOrder\"", retElement.getFirstChild().getNodeValue());
}
示例5: testDocBareDispatchService
import javax.xml.ws.Dispatch; //导入方法依赖的package包/类
@Test
@RunAsClient
public void testDocBareDispatchService() throws Exception
{
QName serviceName = new QName(targetNS, "DocBareService");
QName portName = new QName(targetNS, "DocBarePort");
URL wsdlURL = new URL(baseURL + "/DocBareService?wsdl");
Service service = Service.create(wsdlURL, serviceName);
JAXBContext jbc = JAXBContext.newInstance(new Class[] { SubmitBareRequest.class, SubmitBareResponse.class });
@SuppressWarnings("rawtypes")
Dispatch dispatch = service.createDispatch(portName, jbc, Mode.PAYLOAD);
SubmitBareRequest poReq = new SubmitBareRequest("Ferrari");
@SuppressWarnings("unchecked")
SubmitBareResponse poRes = (SubmitBareResponse)dispatch.invoke(poReq);
assertEquals("Ferrari", poRes.getProduct());
}
示例6: 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());
}
示例7: main
import javax.xml.ws.Dispatch; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, TransformerException {
try {
String address = deployWebservice();
Service service = Service.create(new URL(address), ServiceImpl.SERVICE_NAME);
Dispatch<Source> d = service.createDispatch(ServiceImpl.PORT_NAME, Source.class, Service.Mode.MESSAGE);
Source response = d.invoke(new StreamSource(new StringReader(XML_REQUEST)));
String resultXml = toString(response);
log("= request ======== \n");
log(XML_REQUEST);
log("= result ========= \n");
log(resultXml);
log("\n==================");
boolean xsAnyMixedPartSame = resultXml.contains(XS_ANY_MIXED_PART);
log("resultXml.contains(XS_ANY_PART) = " + xsAnyMixedPartSame);
if (!xsAnyMixedPartSame) {
fail("The xs:any content=mixed part is supposed to be same in request and response.");
throw new RuntimeException();
}
log("TEST PASSED");
} finally {
stopWebservice();
// if you need to debug or explore wsdl generation result
// comment this line out:
deleteGeneratedFiles();
}
}
示例8: invokeObjectDispatch
import javax.xml.ws.Dispatch; //导入方法依赖的package包/类
private void invokeObjectDispatch(final Dispatch<Object> dispatch) throws Exception
{
Echo request = new Echo();
final UserType user = createUser();
request.setArg0(user);
EchoResponse response = (EchoResponse)dispatch.invoke(request);
assertEquals(response.getReturn(), user);
}
示例9: testProviderDispatch
import javax.xml.ws.Dispatch; //导入方法依赖的package包/类
@Test
@RunAsClient
public void testProviderDispatch() throws Exception
{
Dispatch<Source> dispatch = createDispatch("ProviderEndpoint");
Source resPayload = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
Element docElement = DOMUtils.sourceToElement(resPayload);
assertEquals("wrong namespace: " + docElement.getNamespaceURI(), "http://org.jboss.ws/httpbinding", docElement.getNamespaceURI());
assertEquals("wrong localPart: " + docElement.getLocalName(), "somePayload", docElement.getLocalName());
String responseString = DOMUtils.getTextContent(docElement);
assertEquals("wrong content: " + responseString, "Hello:InboundLogicalHandler:OutboundLogicalHandler", responseString);
}
示例10: testCall
import javax.xml.ws.Dispatch; //导入方法依赖的package包/类
@Test
@RunAsClient
public void testCall() throws Exception
{
String text = "http://" + getServerHost() + ":" + getServerPort() + "/jaxws-jbws2978";
String requestMessage = "<S:Envelope xmlns:S='http://schemas.xmlsoap.org/soap/envelope/'><S:Header><To xmlns='http://www.w3.org/2005/08/addressing'>"
+ text
+ "</To><Action xmlns='http://www.w3.org/2005/08/addressing'>inputAction</Action>"
+ "<MessageID xmlns='http://www.w3.org/2005/08/addressing'>uuid:56d586f8-980c-48cf-982d-77a2f56e5c5b</MessageID>"
+ "<ReplyTo xmlns='http://www.w3.org/2005/08/addressing'><Address>http://www.w3.org/2005/08/addressing/anonymous</Address></ReplyTo>"
+ "</S:Header><S:Body><ns1:addNumbers xmlns:ns1='http://ws.jboss.org'><arg0>10</arg0><arg1>10</arg1></ns1:addNumbers></S:Body></S:Envelope>";
URL wsdlURL = new URL(text + "?wsdl");
QName serviceName = new QName("http://ws.jboss.org", "AddNumbers");
Service service = Service.create(wsdlURL, serviceName);
try
{
Dispatch<SOAPMessage> dispatch = service.createDispatch(new QName("http://ws.jboss.org", "AddNumbersPort"), SOAPMessage.class ,
Service.Mode.MESSAGE);
SOAPMessage reqMsg = MessageFactory.newInstance().createMessage(null,
new ByteArrayInputStream(requestMessage.getBytes()));
BindingProvider bp = dispatch;
java.util.Map<String, Object> requestContext = bp.getRequestContext();
requestContext.put(BindingProvider.SOAPACTION_URI_PROPERTY, "mismatchAction");
dispatch.invoke(reqMsg);
fail("Should throw SOAPFaultExceptoin");
}
catch (SOAPFaultException e)
{
assertEquals(true, e.getFault().getFaultCode().indexOf("ActionMismatch") > -1);
}
}
示例11: testProviderDispatch
import javax.xml.ws.Dispatch; //导入方法依赖的package包/类
@Test
@RunAsClient
public void testProviderDispatch() throws Exception
{
Dispatch<Object> dispatch = createDispatch("ProviderEndpoint");
UserType user = new UserType();
user.setString("Kermit");
user.setQname(new QName("TheFrog"));
UserType userRes = (UserType)dispatch.invoke(user);
assertEquals(user.getString(), userRes.getString());
assertEquals(user.getQname(), userRes.getQname());
}
示例12: testCustomClientConfigurationOnDispatch
import javax.xml.ws.Dispatch; //导入方法依赖的package包/类
public boolean testCustomClientConfigurationOnDispatch() throws Exception
{
final String reqString = "<ns1:echo xmlns:ns1=\"http://clientConfig.jaxws.ws.test.jboss.org/\"><arg0>Kermit</arg0></ns1:echo>";
QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
QName portName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointPort");
URL wsdlURL = new URL(address + "?wsdl");
final String testConfigName = "MyTestConfig";
try
{
//-- add test client configuration
TestUtils.addTestCaseClientConfiguration(testConfigName);
// --
Service service = Service.create(wsdlURL, serviceName);
Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
BindingProvider bp = (BindingProvider)dispatch;
@SuppressWarnings("rawtypes")
List<Handler> hc = bp.getBinding().getHandlerChain();
hc.add(new UserHandler());
bp.getBinding().setHandlerChain(hc);
ClientConfigUtil.setConfigHandlers(bp, null, testConfigName);
Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
}
finally
{
// -- remove test client configuration --
TestUtils.removeTestCaseClientConfiguration(testConfigName);
// --
}
}
示例13: testDocBareServiceMessageAccess
import javax.xml.ws.Dispatch; //导入方法依赖的package包/类
@Test
@RunAsClient
public void testDocBareServiceMessageAccess() throws Exception
{
QName serviceName = new QName(targetNS, "DocBareService");
QName portName = new QName(targetNS, "DocBarePort");
URL wsdlURL = new URL(baseURL + "/DocBareService?wsdl");
Service service = Service.create(wsdlURL, serviceName);
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
String reqEnv =
"<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
" <env:Header/>" +
" <env:Body>" +
" <ns1:SubmitPO xmlns:ns1='" + targetNS + "'>" +
" <ns1:product>Ferrari</ns1:product>" +
" </ns1:SubmitPO>" +
" </env:Body>" +
"</env:Envelope>";
SOAPMessage reqMsg = MessageFactory.newInstance().createMessage(null, new ByteArrayInputStream(reqEnv.getBytes()));
SOAPMessage resMsg = dispatch.invoke(reqMsg);
QName qname = new QName(targetNS, "SubmitPOResponse");
SOAPElement soapElement = (SOAPElement)resMsg.getSOAPBody().getChildElements(qname).next();
soapElement = (SOAPElement)soapElement.getChildElements(new QName(targetNS, "product")).next();
assertEquals("Ferrari", soapElement.getValue());
}
示例14: testNamespacedDocBareServiceMessageAccess
import javax.xml.ws.Dispatch; //导入方法依赖的package包/类
@Test
@RunAsClient
public void testNamespacedDocBareServiceMessageAccess() throws Exception
{
QName serviceName = new QName(targetNS, "DocBareService");
QName portName = new QName(targetNS, "DocBarePort");
URL wsdlURL = new URL(baseURL + "/DocBareService?wsdl");
Service service = Service.create(wsdlURL, serviceName);
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
String requestNamespace = "http://namespace/request";
String resultNamespace = "http://namespace/result";
String reqEnv =
"<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
" <env:Header/>" +
" <env:Body>" +
" <ns1:SubmitNamespacedPO xmlns:ns1='" + requestNamespace+ "'>" +
" <ns2:product xmlns:ns2='" + targetNS + "'>Ferrari</ns2:product>" +
" </ns1:SubmitNamespacedPO>" +
" </env:Body>" +
"</env:Envelope>";
SOAPMessage reqMsg = MessageFactory.newInstance().createMessage(null, new ByteArrayInputStream(reqEnv.getBytes()));
SOAPMessage resMsg = dispatch.invoke(reqMsg);
QName qname = new QName(resultNamespace, "SubmitBareResponse");
SOAPElement soapElement = (SOAPElement)resMsg.getSOAPBody().getChildElements(qname).next();
soapElement = (SOAPElement)soapElement.getChildElements(new QName(targetNS, "product")).next();
assertEquals("Ferrari", soapElement.getValue());
}
示例15: testDocWrappedServiceMessageAccess
import javax.xml.ws.Dispatch; //导入方法依赖的package包/类
@Test
@RunAsClient
public void testDocWrappedServiceMessageAccess() throws Exception
{
MessageFactory msgFactory = MessageFactory.newInstance();
String reqEnv =
"<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
" <env:Header/>" +
" <env:Body>" +
" <ns1:SubmitPO xmlns:ns1='" + targetNS + "'>" +
" <PurchaseOrder>Ferrari</PurchaseOrder>" +
" </ns1:SubmitPO>" +
" </env:Body>" +
"</env:Envelope>";
SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(reqEnv.getBytes()));
URL wsdlURL = new URL(baseURL + "/DocWrappedService?wsdl");
QName serviceName = new QName(targetNS, "DocWrappedService");
QName portName = new QName(targetNS, "DocWrappedPort");
Service service = Service.create(wsdlURL, serviceName);
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
SOAPMessage resMsg = dispatch.invoke(reqMsg);
QName qname = new QName(targetNS, "SubmitPOResponse");
SOAPElement soapElement = (SOAPElement)resMsg.getSOAPBody().getChildElements(qname).next();
soapElement = (SOAPElement)soapElement.getChildElements(new QName("PurchaseOrderAck")).next();
assertEquals("Ferrari", soapElement.getValue());
}