当前位置: 首页>>代码示例>>Java>>正文


Java Dispatch.invoke方法代码示例

本文整理汇总了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
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:18,代码来源:CalendarTestCase.java

示例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());
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:19,代码来源:JBWS1807TestCase.java

示例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);
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:17,代码来源:ProviderMessageTestCase.java

示例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());
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:22,代码来源:JBWS1611TestCase.java

示例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());
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:19,代码来源:SOAPBindingTestCase.java

示例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());
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:26,代码来源:OneWayTestCase.java

示例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();
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:Test.java

示例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);
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:9,代码来源:JBWS2937TestCase.java

示例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);
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:14,代码来源:HttpPayloadTestCase.java

示例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);
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:34,代码来源:JBWS2978TestCase.java

示例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());
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:14,代码来源:HttpJAXBTestCase.java

示例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);
      // --
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:39,代码来源:Helper.java

示例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());
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:30,代码来源:SOAPBindingTestCase.java

示例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());
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:33,代码来源:SOAPBindingTestCase.java

示例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());
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:31,代码来源:SOAPBindingTestCase.java


注:本文中的javax.xml.ws.Dispatch.invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。