Java 类javax.xml.ws.Service.Mode 实例源码

项目:jbossws-cxf    文件:CalendarTestCase.java   
@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
}
项目:OpenJSharp    文件:Stubs.java   
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portName
 *      see {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param next
 *      see <a href="#param">common parameters</a>
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
@SuppressWarnings("unchecked")
    public static <T> Dispatch<T> createDispatch(QName portName,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode, Tube next,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portName, owner, binding, next, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        return (Dispatch<T>) createPacketDispatch(portName, owner, binding, next, epr);
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
项目:OpenJSharp    文件:Stubs.java   
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portInfo
 *      see <a href="#param">common parameters</a>
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
public static <T> Dispatch<T> createDispatch(WSPortInfo portInfo,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createPacketDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Packet>");
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
项目:openjdk-jdk10    文件:Stubs.java   
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portName
 *      see {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param next
 *      see <a href="#param">common parameters</a>
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
@SuppressWarnings("unchecked")
    public static <T> Dispatch<T> createDispatch(QName portName,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode, Tube next,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portName, owner, binding, next, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        return (Dispatch<T>) createPacketDispatch(portName, owner, binding, next, epr);
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
项目:openjdk-jdk10    文件:Stubs.java   
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portInfo
 *      see <a href="#param">common parameters</a>
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
public static <T> Dispatch<T> createDispatch(WSPortInfo portInfo,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createPacketDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Packet>");
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
项目:openjdk9    文件:Stubs.java   
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portName
 *      see {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param next
 *      see <a href="#param">common parameters</a>
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
@SuppressWarnings("unchecked")
    public static <T> Dispatch<T> createDispatch(QName portName,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode, Tube next,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portName, owner, binding, next, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        return (Dispatch<T>) createPacketDispatch(portName, owner, binding, next, epr);
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
项目:openjdk9    文件:Stubs.java   
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portInfo
 *      see <a href="#param">common parameters</a>
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
public static <T> Dispatch<T> createDispatch(WSPortInfo portInfo,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createPacketDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Packet>");
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
项目:lookaside_java-1.8.0-openjdk    文件:Stubs.java   
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portName
 *      see {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param next
 *      see <a href="#param">common parameters</a>
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
@SuppressWarnings("unchecked")
    public static <T> Dispatch<T> createDispatch(QName portName,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode, Tube next,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portName, owner, binding, next, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        return (Dispatch<T>) createPacketDispatch(portName, owner, binding, next, epr);
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
项目:lookaside_java-1.8.0-openjdk    文件:Stubs.java   
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portInfo
 *      see <a href="#param">common parameters</a>
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
public static <T> Dispatch<T> createDispatch(WSPortInfo portInfo,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createPacketDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Packet>");
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
项目:jbossws-cxf    文件:Helper.java   
public boolean testConfigurationChangeOnDispatch() throws Exception
{
   Service service = Service.create(new URL(address + "?wsdl"), serviceName);
   Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
   org.apache.cxf.endpoint.Endpoint ep = ((DispatchImpl<SOAPMessage>)dispatch).getClient().getEndpoint();
   assert(ep.get("propA") == null);
   assert(ep.get("propB") == null);
   ep.put("propZ", "valueZ");

   ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
   configurer.setConfigProperties(dispatch, "META-INF/jaxws-client-config.xml", "Custom Client Config");

   if (!ep.get("propA").equals("fileValueA") || !ep.get("propB").equals("fileValueB") || !ep.get("propZ").equals("valueZ")) {
      return false;
   }

   configurer.setConfigProperties(dispatch, "META-INF/jaxws-client-config.xml", "Another Client Config");

   return (ep.get("propA") == null && ep.get("propB") == null && ep.get("propC").equals("fileValueC") && ep.get("propZ").equals("valueZ"));
}
项目:jbossws-cxf    文件:Helper.java   
public boolean testDefaultClientConfigurationOnDispatch() throws Exception
{
   final URL wsdlURL = new URL(address + "?wsdl");
   final ClientConfig defaultClientConfig = TestUtils.getAndVerifyDefaultClientConfiguration();

   // -- modify default conf --
   try
   {
      final Map<String, String> props = new HashMap<String, String>();
      props.put("propA", "valueA");
      TestUtils.registerClientConfigAndReload(new ClientConfig(defaultClientConfig.getConfigName(), null, null, props, null));
      // --

      Service service = Service.create(wsdlURL, serviceName);
      Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);

      return (((DispatchImpl<SOAPMessage>)dispatch).getClient().getEndpoint().get("propA").equals("valueA"));
   }
   finally
   {
      // -- restore default conf --
      TestUtils.registerClientConfigAndReload(defaultClientConfig);
      // --
   }
}
项目:jbossws-cxf    文件:Helper.java   
public boolean testCustomClientConfigurationOnDispatch() throws Exception
{
   final 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<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
      org.apache.cxf.endpoint.Endpoint ep = ((DispatchImpl<SOAPMessage>)dispatch).getClient().getEndpoint();
      ep.put("propZ", "valueZ");

      ClientConfigUtil.setConfigProperties(dispatch, null, testConfigName);

      return (ep.get("propT").equals("valueT") && ep.get("propZ").equals("valueZ"));
   }
   finally
   {
      // -- remove test client configuration --
      TestUtils.removeTestCaseClientConfiguration(testConfigName);
      // --
   }
}
项目:jbossws-cxf    文件:Helper.java   
public boolean testCustomClientConfigurationOnDispatchUsingFeature() throws Exception
{
   final 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<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE, new ClientConfigFeature(null, testConfigName, true));
      org.apache.cxf.endpoint.Endpoint ep = ((DispatchImpl<SOAPMessage>)dispatch).getClient().getEndpoint();
      ep.put("propZ", "valueZ");

      return (ep.get("propT").equals("valueT") && ep.get("propZ").equals("valueZ"));
   }
   finally
   {
      // -- remove test client configuration --
      TestUtils.removeTestCaseClientConfiguration(testConfigName);
      // --
   }
}
项目:jbossws-cxf    文件:JBWS2937TestCase.java   
@Test
@RunAsClient
public void testCreateDispatchUsingEPRAndSource() throws Exception
{
   Dispatch<Source> dispatch = service.createDispatch(PORT_QNAME, Source.class, Mode.PAYLOAD);
   assertNotNull("Dispatch is null", dispatch);
   this.invokeSourceDispatch(dispatch);
   epr = dispatch.getEndpointReference();
   printEPR(epr);

   dispatch = service.createDispatch(epr, Source.class, Service.Mode.PAYLOAD, ADDRESSING_ENABLED);
   assertNotNull("Dispatch is null", dispatch);
   this.invokeSourceDispatch(dispatch);
   epr = dispatch.getEndpointReference();
   printEPR(epr);

   dispatch = service.createDispatch(epr, Source.class, Service.Mode.PAYLOAD, ADDRESSING_DISABLED);
   assertNotNull("Dispatch is null", dispatch);
   this.invokeSourceDispatch(dispatch);
   epr = dispatch.getEndpointReference();
   printEPR(epr);
}
项目:jbossws-cxf    文件:JBWS2937TestCase.java   
@Test
@RunAsClient
public void testCreateDispatchUsingEPRAndJAXBContext() throws Exception
{
   Dispatch<Object> dispatch = service.createDispatch(PORT_QNAME, this.createJAXBContext(), Mode.PAYLOAD);
   assertNotNull("Dispatch is null", dispatch);
   this.invokeObjectDispatch(dispatch);
   epr = dispatch.getEndpointReference();
   printEPR(epr);

   dispatch = service.createDispatch(epr, this.createJAXBContext(), Service.Mode.PAYLOAD, ADDRESSING_ENABLED);
   assertNotNull("Dispatch is null", dispatch);
   this.invokeObjectDispatch(dispatch);
   epr = dispatch.getEndpointReference();
   printEPR(epr);

   dispatch = service.createDispatch(epr, this.createJAXBContext(), Service.Mode.PAYLOAD, ADDRESSING_DISABLED);
   assertNotNull("Dispatch is null", dispatch);
   this.invokeObjectDispatch(dispatch);
   epr = dispatch.getEndpointReference();
   printEPR(epr);
}
项目:jbossws-cxf    文件:JBWS1807TestCase.java   
@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());
}
项目:jbossws-cxf    文件:Helper.java   
public boolean testCustomClientConfigurationOnDispatchFromFile() 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");

   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, "META-INF/jaxws-client-config.xml", "Custom Client Config");

   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|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
}
项目:jbossws-cxf    文件:Helper.java   
public boolean testCustomClientConfigurationFromFileUsingFeatureOnDispatch() 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");

   Service service = Service.create(wsdlURL, serviceName);
   Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD,
         new ClientConfigFeature("META-INF/jaxws-client-config.xml", "Custom Client Config"));

   BindingProvider bp = (BindingProvider)dispatch;
   @SuppressWarnings("rawtypes")
   List<Handler> hc = bp.getBinding().getHandlerChain();
   hc.add(new UserHandler());
   bp.getBinding().setHandlerChain(hc);

   Source 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|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
}
项目:jbossws-cxf    文件:JBWS1611TestCase.java   
@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());
}
项目:jbossws-cxf    文件:SOAPBindingTestCase.java   
@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());
}
项目:jbossws-cxf    文件:OneWayTestCase.java   
@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());
}
项目:jbossws-cxf    文件:WebMethodTestCase.java   
@Test
@RunAsClient
public void testIllegalDispatchAccess() throws Exception
{
   URL wsdlURL = new URL(baseURL + "/TestService?wsdl");
   QName serviceName = new QName(targetNS, "EndpointService");
   QName portName = new QName(targetNS, "EndpointPort");

   String reqPayload =
      "<ns1:noWebMethod xmlns:ns1='" + targetNS + "'>" +
      " <String_1>Hello</String_1>" +
      "</ns1:noWebMethod>";

   Service service = Service.create(wsdlURL, serviceName);
   Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
   try
   {
      dispatch.invoke(new StreamSource(new StringReader(reqPayload)));
      fail("SOAPFaultException expected");
   }
   catch (SOAPFaultException ex)
   {
      // ignore
   }
}
项目:infobip-open-jdk-8    文件:Stubs.java   
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portName
 *      see {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param next
 *      see <a href="#param">common parameters</a>
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
@SuppressWarnings("unchecked")
    public static <T> Dispatch<T> createDispatch(QName portName,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode, Tube next,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portName, owner, binding, next, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        return (Dispatch<T>) createPacketDispatch(portName, owner, binding, next, epr);
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
项目:infobip-open-jdk-8    文件:Stubs.java   
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portInfo
 *      see <a href="#param">common parameters</a>
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
public static <T> Dispatch<T> createDispatch(WSPortInfo portInfo,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createPacketDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Packet>");
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
项目:teiid    文件:WSConnectionImpl.java   
public <T> Dispatch<T> createDispatch(Class<T> type, Mode mode) throws IOException {
    if (this.wsdlService == null) {
        Bus bus = BusFactory.getThreadDefaultBus();
        BusFactory.setThreadDefaultBus(this.mcf.getBus());
        try {
            this.wsdlService = Service.create(this.mcf.getWsdlUrl(), this.mcf.getServiceQName());
        } finally {
            BusFactory.setThreadDefaultBus(bus);
        }
        if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
            LogManager.logDetail(LogConstants.CTX_WS, "Created the WSDL service for", this.mcf.getWsdl()); //$NON-NLS-1$
        }
    }
    Dispatch<T> dispatch = this.wsdlService.createDispatch(this.mcf.getPortQName(), type, mode);
    configureWSSecurity(dispatch);
    setDispatchProperties(dispatch, "SOAP12"); //$NON-NLS-1$
    return dispatch;
}
项目:OLD-OpenJDK8    文件:Stubs.java   
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portName
 *      see {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param next
 *      see <a href="#param">common parameters</a>
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
@SuppressWarnings("unchecked")
    public static <T> Dispatch<T> createDispatch(QName portName,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode, Tube next,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portName, owner, binding, mode, next, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portName, owner, binding, next, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        return (Dispatch<T>) createPacketDispatch(portName, owner, binding, next, epr);
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
项目:OLD-OpenJDK8    文件:Stubs.java   
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portInfo
 *      see <a href="#param">common parameters</a>
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
public static <T> Dispatch<T> createDispatch(WSPortInfo portInfo,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createPacketDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Packet>");
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
项目:wso2-axis2    文件:OMProviderTests.java   
/**
 * Test sending a SOAP 1.2 request in MESSAGE mode
 */
public void testOMElementDispatchMessageMode() throws Exception {
    // Create the JAX-WS client needed to send the request
    Service service = Service.create(serviceName);
    service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl);
    Dispatch<OMElement> dispatch = service.createDispatch(
            portName, OMElement.class, Mode.MESSAGE);

    // Create the OMElement object with the payload contents.  Since
    // we're in PAYLOAD mode, we don't have to worry about the envelope.
    StringReader sr = new StringReader(SOAP11_ENVELOPE_HEAD+request+SOAP11_ENVELOPE_TAIL);
    XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inputReader, null); 
    SOAPEnvelope om = (SOAPEnvelope) builder.getDocumentElement();


    OMElement response = dispatch.invoke(om);


    String responseText = response.toStringWithConsume();
    assertTrue(responseText.contains("soap"));
    assertTrue(responseText.contains("Body"));
    assertTrue(responseText.contains("Envelope"));
    assertTrue(responseText.contains("Hello Dispatch OM"));

}
项目:wso2-axis2    文件:OMProviderTests.java   
/**
 * Test sending a SOAP 1.2 request in MESSAGE mode
 */
public void testOMElementDispatchMessageModeSOAPFaultException() throws Exception {
    // Create the JAX-WS client needed to send the request
    Service service = Service.create(serviceName);
    service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl);
    Dispatch<OMElement> dispatch = service.createDispatch(
            portName, OMElement.class, Mode.MESSAGE);

    StringReader sr = new StringReader(SOAP11_ENVELOPE_HEAD+SOAPFaultRequest+SOAP11_ENVELOPE_TAIL);
    XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inputReader, null); 
    SOAPEnvelope om = (SOAPEnvelope) builder.getDocumentElement();
    OMElement response = null;
    try{
        response = dispatch.invoke(om);
        String responseText = response.toStringWithConsume();
    }catch(Exception e){
        assertTrue(e instanceof SOAPFaultException);
    }
    assertTrue(response ==null);
}
项目:wso2-axis2    文件:OMProviderTests.java   
public void testOMElementDispatchMessageModeSOAPFault() throws Exception {
    // Create the JAX-WS client needed to send the request
    Service service = Service.create(serviceName);
    service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl);
    Dispatch<OMElement> dispatch = service.createDispatch(
            portName, OMElement.class, Mode.MESSAGE);
    BindingProvider bp = (BindingProvider)dispatch;
    bp.getRequestContext().put(Constants.THROW_EXCEPTION_IF_SOAP_FAULT, Boolean.FALSE);

    StringReader sr = new StringReader(SOAP11_ENVELOPE_HEAD+SOAPFaultRequest+SOAP11_ENVELOPE_TAIL);
    XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inputReader, null); 
    SOAPEnvelope om = (SOAPEnvelope) builder.getDocumentElement();
    OMElement response = null;
    try{
        response = dispatch.invoke(om);
        String responseText = response.toStringWithConsume();
    }catch(Exception e){
        fail();
    }
    assertTrue(response !=null);
    assertTrue(response instanceof OMElement);
}
项目:wso2-axis2    文件:ParamTests.java   
public void testNullSoapParamWithMessageMode() {
    QName serviceName = new QName("http://test", "MyService");
    QName portName = new QName("http://test", "MyPort");

    Service svc = Service.create(serviceName);
    svc.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, "http://localhost");

    Dispatch<Source> dispatch = svc.createDispatch(portName, 
            Source.class, Mode.PAYLOAD);

    boolean handled = false;
    try {
        dispatch.invoke(null);    
    }
    catch (WebServiceException wse) {
        handled = true;
    }        

    assertTrue("A WebServiceException should be thrown for this null param", handled);
}
项目:wso2-axis2    文件:StreamSourceDispatchTests.java   
/**
 * Invoke a Dispatch<Source> one-way operation
 */
public void testOneWayPayloadMode() throws Exception {
    TestLogger.logger.debug("---------------------------------------");
    TestLogger.logger.debug("test: " + getName());

    // Initialize the JAX-WS client artifacts
    Service svc = Service.create(DispatchTestConstants.QNAME_SERVICE);
    svc.addPort(DispatchTestConstants.QNAME_PORT, null, DispatchTestConstants.URL);
    Dispatch<Source> dispatch = svc.createDispatch(DispatchTestConstants.QNAME_PORT, Source.class,
                                                   Service.Mode.PAYLOAD);

    // Create a StreamSource with the desired content
    byte[] bytes = DispatchTestConstants.sampleBodyContent.getBytes();
    ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
    Source srcStream = new StreamSource((InputStream) stream);

    TestLogger.logger.debug(">> Invoking One Way Dispatch");
    dispatch.invokeOneWay(srcStream);

    // Invoke a second time to verify
    stream = new ByteArrayInputStream(bytes);
    srcStream = new StreamSource((InputStream) stream);

    TestLogger.logger.debug(">> Invoking One Way Dispatch");
    dispatch.invokeOneWay(srcStream);
}
项目:openjdk-icedtea7    文件:Stubs.java   
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portInfo
 *      see <a href="#param">common parameters</a>
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
public static <T> Dispatch<T> createDispatch(WSPortInfo portInfo,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
项目:bandwidth-on-demand    文件:AsyncSoapClient.java   
/**
 * Sends the reply to the endpoint, taking a detour via stunnel when required
 */
@Async
public void asyncSend(URI endPoint, String soapAction, SOAPMessage message, String nsaId, Consumer<SOAPMessage> responseConsumer, Consumer<SOAPFault> faultConsumer) {
  final Optional<URI> stunnelUri = findStunnelUri(nsaId, endPoint);
  URI endpointAddress = stunnelUri.orElse(endPoint);

  try {
    Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);

    Map<String, Object> requestContext = dispatch.getRequestContext();
    requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress.toASCIIString());
    requestContext.put(JAXWSProperties.CONNECT_TIMEOUT, connectTimeout);
    requestContext.put(JAXWSProperties.REQUEST_TIMEOUT, requestTimeout);
    requestContext.put(Dispatch.SOAPACTION_USE_PROPERTY, true);
    requestContext.put(Dispatch.SOAPACTION_URI_PROPERTY, soapAction);

    responseConsumer.accept(dispatch.invoke(message));
  } catch (Exception e) {
    LOGGER.warn("{}: Failed to send {} to {} ({}): {}", this, soapAction, endPoint, stunnelUri, e, e);
    if (e instanceof SOAPFaultException) {
      faultConsumer.accept(((SOAPFaultException) e).getFault());
    }
  }
}
项目:securibench-jaxws    文件:OneWayTestCase.java   
public void testWebService() throws Exception
{
   URL wsdlURL = new URL("http://localhost:8080/jaxws-samples-oneway/TestService?wsdl");
   QName serviceName = new QName(targetNS, "PingEndpointService");
   QName portName = new QName(targetNS, "PingEndpointPort");
   Service service = Service.create(wsdlURL, serviceName);
   Dispatch 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 3 sec as invokeOneWay is supposed to be non-blocking subject to the capabilities of the underlying protocol
   Thread.sleep(3000);

   payload = "<ns1:feedback xmlns:ns1='http://oneway.samples.jaxws.ws.test.jboss.org/'/>";
   Source retObj = (Source)dispatch.invoke(new StreamSource(new StringReader(payload)));      
}
项目:OpenJSharp    文件:DispatchImpl.java   
static void checkNullAllowed(@Nullable Object in, RequestContext rc, WSBinding binding, Service.Mode mode) {

        if (in != null)
            return;

        //With HTTP Binding a null invocation parameter can not be used
        //with HTTP Request Method == POST
        if (isXMLHttp(binding)){
            if (methodNotOk(rc))
                throw new WebServiceException(DispatchMessages.INVALID_NULLARG_XMLHTTP_REQUEST_METHOD(HTTP_REQUEST_METHOD_POST, HTTP_REQUEST_METHOD_GET));
        } else { //soapBinding
              if (mode == Service.Mode.MESSAGE )
                   throw new WebServiceException(DispatchMessages.INVALID_NULLARG_SOAP_MSGMODE(mode.name(), Service.Mode.PAYLOAD.toString()));
        }
    }
项目:OpenJSharp    文件:DispatchImpl.java   
public static void checkValidSOAPMessageDispatch(WSBinding binding, Service.Mode mode) {
    // Dispatch<SOAPMessage> is only valid for soap binding and in Service.Mode.MESSAGE
    if (DispatchImpl.isXMLHttp(binding))
        throw new WebServiceException(DispatchMessages.INVALID_SOAPMESSAGE_DISPATCH_BINDING(HTTPBinding.HTTP_BINDING, SOAPBinding.SOAP11HTTP_BINDING + " or " + SOAPBinding.SOAP12HTTP_BINDING));
    if (DispatchImpl.isPAYLOADMode(mode))
        throw new WebServiceException(DispatchMessages.INVALID_SOAPMESSAGE_DISPATCH_MSGMODE(mode.name(), Service.Mode.MESSAGE.toString()));
}
项目:OpenJSharp    文件:DispatchImpl.java   
public static void checkValidDataSourceDispatch(WSBinding binding, Service.Mode mode) {
    // Dispatch<DataSource> is only valid with xml/http binding and in Service.Mode.MESSAGE
    if (!DispatchImpl.isXMLHttp(binding))
        throw new WebServiceException(DispatchMessages.INVALID_DATASOURCE_DISPATCH_BINDING("SOAP/HTTP", HTTPBinding.HTTP_BINDING));
    if (DispatchImpl.isPAYLOADMode(mode))
        throw new WebServiceException(DispatchMessages.INVALID_DATASOURCE_DISPATCH_MSGMODE(mode.name(), Service.Mode.MESSAGE.toString()));
}
项目:OpenJSharp    文件:DispatchImpl.java   
@Deprecated
public static Dispatch<Source> createSourceDispatch(QName port, Mode mode, WSServiceDelegate owner, Tube pipe, BindingImpl binding, WSEndpointReference epr) {
    if(isXMLHttp(binding))
        return new RESTSourceDispatch(port,mode,owner,pipe,binding,epr);
    else
        return new SOAPSourceDispatch(port,mode,owner,pipe,binding,epr);
}
项目:openjdk-jdk10    文件:DispatchImpl.java   
static void checkNullAllowed(@Nullable Object in, RequestContext rc, WSBinding binding, Service.Mode mode) {

        if (in != null)
            return;

        //With HTTP Binding a null invocation parameter can not be used
        //with HTTP Request Method == POST
        if (isXMLHttp(binding)){
            if (methodNotOk(rc))
                throw new WebServiceException(DispatchMessages.INVALID_NULLARG_XMLHTTP_REQUEST_METHOD(HTTP_REQUEST_METHOD_POST, HTTP_REQUEST_METHOD_GET));
        } else { //soapBinding
              if (mode == Service.Mode.MESSAGE )
                   throw new WebServiceException(DispatchMessages.INVALID_NULLARG_SOAP_MSGMODE(mode.name(), Service.Mode.PAYLOAD.toString()));
        }
    }