Java 类javax.xml.ws.soap.SOAPBinding 实例源码

项目:OpenJSharp    文件:HandlerConfigurator.java   
void configureHandlers(WSPortInfo port, BindingImpl binding) {
    //Check in cache first
    HandlerAnnotationInfo chain = chainMap.get(port);

    if(chain==null) {
        logGetChain(port);
        // Put it in cache
        chain = handlerModel.getHandlersForPortInfo(port);
        chainMap.put(port,chain);
    }

    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(chain.getRoles());
    }

    logSetChain(port,chain);
    binding.setHandlerChain(chain.getHandlers());
}
项目:OpenJSharp    文件:DeploymentDescriptorParser.java   
/**
 * Parses the handler and role information and sets it
 * on the {@link WSBinding}.
 *
 * @return true if <handler-chains> element present in DD
 *         false otherwise.
 */
protected boolean setHandlersAndRoles(WSBinding binding, XMLStreamReader reader, QName serviceName, QName portName) {

    if (reader.getEventType() == XMLStreamConstants.END_ELEMENT ||
            !reader.getName().equals(HandlerChainsModel.QNAME_HANDLER_CHAINS)) {
        return false;
    }

    HandlerAnnotationInfo handlerInfo = HandlerChainsModel.parseHandlerFile(
            reader, classLoader, serviceName, portName, binding);

    binding.setHandlerChain(handlerInfo.getHandlers());
    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(handlerInfo.getRoles());
    }

    // move past </handler-chains>
    XMLStreamReaderUtil.nextContent(reader);
    return true;
}
项目:openjdk-jdk10    文件:HandlerConfigurator.java   
void configureHandlers(WSPortInfo port, BindingImpl binding) {
    //Check in cache first
    HandlerAnnotationInfo chain = chainMap.get(port);

    if(chain==null) {
        logGetChain(port);
        // Put it in cache
        chain = handlerModel.getHandlersForPortInfo(port);
        chainMap.put(port,chain);
    }

    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(chain.getRoles());
    }

    logSetChain(port,chain);
    binding.setHandlerChain(chain.getHandlers());
}
项目:openjdk-jdk10    文件:DeploymentDescriptorParser.java   
/**
 * Parses the handler and role information and sets it
 * on the {@link WSBinding}.
 *
 * @return true if <handler-chains> element present in DD
 *         false otherwise.
 */
protected boolean setHandlersAndRoles(WSBinding binding, XMLStreamReader reader, QName serviceName, QName portName) {

    if (reader.getEventType() == XMLStreamConstants.END_ELEMENT ||
            !reader.getName().equals(HandlerChainsModel.QNAME_HANDLER_CHAINS)) {
        return false;
    }

    HandlerAnnotationInfo handlerInfo = HandlerChainsModel.parseHandlerFile(
            reader, classLoader, serviceName, portName, binding);

    binding.setHandlerChain(handlerInfo.getHandlers());
    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(handlerInfo.getRoles());
    }

    // move past </handler-chains>
    XMLStreamReaderUtil.nextContent(reader);
    return true;
}
项目:openjdk9    文件:HandlerConfigurator.java   
void configureHandlers(WSPortInfo port, BindingImpl binding) {
    //Check in cache first
    HandlerAnnotationInfo chain = chainMap.get(port);

    if(chain==null) {
        logGetChain(port);
        // Put it in cache
        chain = handlerModel.getHandlersForPortInfo(port);
        chainMap.put(port,chain);
    }

    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(chain.getRoles());
    }

    logSetChain(port,chain);
    binding.setHandlerChain(chain.getHandlers());
}
项目:openjdk9    文件:DeploymentDescriptorParser.java   
/**
 * Parses the handler and role information and sets it
 * on the {@link WSBinding}.
 *
 * @return true if <handler-chains> element present in DD
 *         false otherwise.
 */
protected boolean setHandlersAndRoles(WSBinding binding, XMLStreamReader reader, QName serviceName, QName portName) {

    if (reader.getEventType() == XMLStreamConstants.END_ELEMENT ||
            !reader.getName().equals(HandlerChainsModel.QNAME_HANDLER_CHAINS)) {
        return false;
    }

    HandlerAnnotationInfo handlerInfo = HandlerChainsModel.parseHandlerFile(
            reader, classLoader, serviceName, portName, binding);

    binding.setHandlerChain(handlerInfo.getHandlers());
    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(handlerInfo.getRoles());
    }

    // move past </handler-chains>
    XMLStreamReaderUtil.nextContent(reader);
    return true;
}
项目:lookaside_java-1.8.0-openjdk    文件:HandlerConfigurator.java   
void configureHandlers(WSPortInfo port, BindingImpl binding) {
    //Check in cache first
    HandlerAnnotationInfo chain = chainMap.get(port);

    if(chain==null) {
        logGetChain(port);
        // Put it in cache
        chain = handlerModel.getHandlersForPortInfo(port);
        chainMap.put(port,chain);
    }

    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(chain.getRoles());
    }

    logSetChain(port,chain);
    binding.setHandlerChain(chain.getHandlers());
}
项目:lookaside_java-1.8.0-openjdk    文件:DeploymentDescriptorParser.java   
/**
 * Parses the handler and role information and sets it
 * on the {@link WSBinding}.
 *
 * @return true if <handler-chains> element present in DD
 *         false otherwise.
 */
protected boolean setHandlersAndRoles(WSBinding binding, XMLStreamReader reader, QName serviceName, QName portName) {

    if (reader.getEventType() == XMLStreamConstants.END_ELEMENT ||
            !reader.getName().equals(HandlerChainsModel.QNAME_HANDLER_CHAINS)) {
        return false;
    }

    HandlerAnnotationInfo handlerInfo = HandlerChainsModel.parseHandlerFile(
            reader, classLoader, serviceName, portName, binding);

    binding.setHandlerChain(handlerInfo.getHandlers());
    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(handlerInfo.getRoles());
    }

    // move past </handler-chains>
    XMLStreamReaderUtil.nextContent(reader);
    return true;
}
项目:Camel    文件:CxfMtomRouterPayloadModeTest.java   
@Test
public void testInvokingServiceFromCXFClient() throws Exception {        
    if (MtomTestHelper.isAwtHeadless(logger, null)) {
        return;
    }

    Holder<byte[]> photo = new Holder<byte[]>(MtomTestHelper.REQ_PHOTO_DATA);
    Holder<Image> image = new Holder<Image>(getImage("/java.jpg"));

    Hello port = getPort();

    SOAPBinding binding = (SOAPBinding) ((BindingProvider)port).getBinding();
    binding.setMTOMEnabled(true);

    port.detail(photo, image);

    MtomTestHelper.assertEquals(MtomTestHelper.RESP_PHOTO_DATA,  photo.value);      
    Assert.assertNotNull(image.value);
    if (image.value instanceof BufferedImage) {
        Assert.assertEquals(560, ((BufferedImage)image.value).getWidth());
        Assert.assertEquals(300, ((BufferedImage)image.value).getHeight());            
    }

}
项目:Camel    文件:CxfMtomConsumerTest.java   
@Test
public void testInvokingService() throws Exception {        
    if (MtomTestHelper.isAwtHeadless(null, log)) {
        return;
    }

    Holder<byte[]> photo = new Holder<byte[]>("RequestFromCXF".getBytes("UTF-8"));
    Holder<Image> image = new Holder<Image>(getImage("/java.jpg"));

    Hello port = getPort();

    SOAPBinding binding = (SOAPBinding) ((BindingProvider)port).getBinding();
    binding.setMTOMEnabled(true);

    port.detail(photo, image);

    assertEquals("ResponseFromCamel", new String(photo.value, "UTF-8"));
    assertNotNull(image.value);

}
项目:jbossws-cxf    文件:JBWS3593TestCase.java   
@Test
@RunAsClient
public void testMTOMAccess() throws Exception
{
   URL wsdlURL = new URL(baseURL + "/EndpointBean?wsdl");
   QName qname = new QName("http://org.jboss.ws/jaxws/jbws3593", "EndpointBeanService");
   Service service = Service.create(wsdlURL, qname);
   Endpoint port = service.getPort(Endpoint.class);

   addClientHandler((BindingProvider)port, true);

   ((SOAPBinding)((BindingProvider)port).getBinding()).setMTOMEnabled(true);

   DataHandler response = port.namespace(new DataHandler("Jimbo","text/plain"));
   Object messg = getContent(response);
   assertEquals("Hello Jimbo", messg);
}
项目:jbossws-cxf    文件:JBWS2000TestCase.java   
@Test
@RunAsClient
public void testFileTransfer() throws Exception
{
   URL wsdlURL = new URL(baseURL + "/jaxws-jbws2000/FileTransfer?wsdl");
   QName serviceName = new QName("http://service.mtom.test.net/", "FileTransferServiceImplService");
   Service service = Service.create(wsdlURL, serviceName);
   FileTransferService port = service.getPort(FileTransferService.class);

   SOAPBinding binding = (SOAPBinding)((BindingProvider)port).getBinding();
   binding.setMTOMEnabled(true);

   GeneratorDataSource source = new GeneratorDataSource(1024 * 1204 * 8); //avoid going beyond Undertow default max post size
   DataHandler dh = new DataHandler(source);

   boolean success = port.transferFile("JBWS2000.data", dh);
   assertTrue("Failed to transfer file", success);
}
项目:jbossws-cxf    文件:JBWS3250TestCase.java   
@Test
@RunAsClient
public void testMtomSawpFile() throws Exception
{
   URL wsdlURL = new URL(baseURL + "?wsdl");
   QName serviceName = new QName("http://ws.jboss.org/jbws3250", "TestEndpointService");
   Endpoint port = Service.create(wsdlURL, serviceName).getPort(Endpoint.class);
   SOAPBinding binding =(SOAPBinding)((BindingProvider)port).getBinding();
   binding.setMTOMEnabled(true);
   URL url = JBossWSTestHelper.getResourceURL("jaxws/jbws3250/wsf.png");
   URLDataSource urlDatasource = new URLDataSource(url);
   javax.activation.DataHandler dh = new DataHandler(urlDatasource);
   MTOMRequest request = new MTOMRequest();
   request.setContent(dh);
   request.setId("largeSize_mtom_request");
   MTOMResponse mtomResponse = port.echo(request);
   Assert.assertEquals("Response for requestID:largeSize_mtom_request", mtomResponse.getResponse());
   byte[] responseBytes = IOUtils.convertToBytes(mtomResponse.getContent());
   Assert.assertTrue(responseBytes.length > 65536);
}
项目:jbossws-cxf    文件:JBWS2419TestCase.java   
@Test
@RunAsClient
public void testSOAP12ClientAccess() throws Exception
{
   URL wsdlURL = new URL(baseURL + "/soap12?wsdl");
   QName qname = new QName("http://org.jboss.ws/jaxws/jbws2419", "SOAP12EndpointBeanService");
   Service service = Service.create(wsdlURL, qname);
   SOAP12Endpoint port = service.getPort(SOAP12Endpoint.class);

   BindingProvider provider = (BindingProvider)port;
   @SuppressWarnings("rawtypes")
   List<Handler> handlerChain = new ArrayList<Handler>();
   handlerChain.addAll(provider.getBinding().getHandlerChain());
   handlerChain.add(new SOAP12ClientHandler());
   provider.getBinding().setHandlerChain(handlerChain);
   ((SOAPBinding)provider.getBinding()).setMTOMEnabled(true);

   DataHandler response = port.namespace(new DataHandler("Jimbo","text/plain"));
   Object messg = getContent(response);
   assertEquals("Hello Jimbo", messg);
}
项目:jbossws-cxf    文件:JBWS2419TestCase.java   
@Test
@RunAsClient
public void testSOAP11ClientAccess() throws Exception
{
   URL wsdlURL = new URL(baseURL + "/soap11?wsdl");
   QName qname = new QName("http://org.jboss.ws/jaxws/jbws2419", "SOAP11EndpointBeanService");
   Service service = Service.create(wsdlURL, qname);
   SOAP11Endpoint port = service.getPort(SOAP11Endpoint.class);

   BindingProvider provider = (BindingProvider)port;
   @SuppressWarnings("rawtypes")
   List<Handler> handlerChain = new ArrayList<Handler>();
   handlerChain.addAll(provider.getBinding().getHandlerChain());
   handlerChain.add(new SOAP11ClientHandler());
   provider.getBinding().setHandlerChain(handlerChain);
   ((SOAPBinding)provider.getBinding()).setMTOMEnabled(true);

   DataHandler response = port.namespace(new DataHandler("Jimbo","text/plain"));
   Object messg = getContent(response);
   assertEquals("Hello Jimbo", messg);
}
项目:jbossws-cxf    文件:XOPWrappedTestCase.java   
@Test
@RunAsClient
public void testParameterAnnotation() throws Exception
{
   QName serviceName = new QName("http://doclit.xop.samples.jaxws.ws.test.jboss.org/", "WrappedService");
   URL wsdlURL = new URL(baseURL + "wrapped?wsdl");

   Service service = Service.create(wsdlURL, serviceName);
   WrappedEndpoint port = service.getPort(WrappedEndpoint.class);

   SOAPBinding binding = (SOAPBinding)((BindingProvider)port).getBinding();
   binding.setMTOMEnabled(true);

   DataHandler request = new DataHandler("Client data", "text/plain");
   DataHandler response = port.parameterAnnotation(request);

   assertNotNull(response);
   Object content = getContent(response);
   String contentType = response.getContentType();

   assertEquals("Server data", content);
   assertEquals("text/plain", contentType);      
}
项目:infobip-open-jdk-8    文件:HandlerConfigurator.java   
void configureHandlers(WSPortInfo port, BindingImpl binding) {
    //Check in cache first
    HandlerAnnotationInfo chain = chainMap.get(port);

    if(chain==null) {
        logGetChain(port);
        // Put it in cache
        chain = handlerModel.getHandlersForPortInfo(port);
        chainMap.put(port,chain);
    }

    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(chain.getRoles());
    }

    logSetChain(port,chain);
    binding.setHandlerChain(chain.getHandlers());
}
项目:infobip-open-jdk-8    文件:DeploymentDescriptorParser.java   
/**
 * Parses the handler and role information and sets it
 * on the {@link WSBinding}.
 *
 * @return true if <handler-chains> element present in DD
 *         false otherwise.
 */
protected boolean setHandlersAndRoles(WSBinding binding, XMLStreamReader reader, QName serviceName, QName portName) {

    if (reader.getEventType() == XMLStreamConstants.END_ELEMENT ||
            !reader.getName().equals(HandlerChainsModel.QNAME_HANDLER_CHAINS)) {
        return false;
    }

    HandlerAnnotationInfo handlerInfo = HandlerChainsModel.parseHandlerFile(
            reader, classLoader, serviceName, portName, binding);

    binding.setHandlerChain(handlerInfo.getHandlers());
    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(handlerInfo.getRoles());
    }

    // move past </handler-chains>
    XMLStreamReaderUtil.nextContent(reader);
    return true;
}
项目:cxf-plus    文件:CXFPlusClientFactoryBean.java   
@Override
public void setBindingId(String bind) {
    if (SOAPBinding.SOAP11HTTP_BINDING.equals(bind) 
        || SOAPBinding.SOAP11HTTP_MTOM_BINDING.equals(bind)) {
        super.setBindingId("http://schemas.xmlsoap.org/wsdl/soap/");
    } else if (SOAPBinding.SOAP12HTTP_BINDING.equals(bind)
        || SOAPBinding.SOAP12HTTP_MTOM_BINDING.equals(bind)) {
        super.setBindingId("http://schemas.xmlsoap.org/wsdl/soap12/");
    } else {
        super.setBindingId(bind);
    }

    if (SOAPBinding.SOAP11HTTP_BINDING.equals(bind)
        || SOAPBinding.SOAP12HTTP_BINDING.equals(bind)) {
        setBindingConfig(new JaxWsSoapBindingConfiguration((JaxWsServiceFactoryBean)getServiceFactory()));
    } else if (SOAPBinding.SOAP11HTTP_MTOM_BINDING.equals(bind)
        || SOAPBinding.SOAP12HTTP_MTOM_BINDING.equals(bind)) {
        setBindingConfig(new JaxWsSoapBindingConfiguration((JaxWsServiceFactoryBean)getServiceFactory()));
        ((JaxWsSoapBindingConfiguration)getBindingConfig()).setMtomEnabled(true);
    }
}
项目:spring-ws-mtom-example    文件:JaxWsClient.java   
/**
 * Sends the test content file to the WebService
 */
public void storeContent() throws Exception {
    ContentStoreHttpPortService contentStoreService = new ContentStoreHttpPortService();
    ContentStoreHttpPort contentStorePort = contentStoreService.getContentStoreHttpPortSoap11();
    SOAPBinding binding = (SOAPBinding) ((BindingProvider) contentStorePort).getBinding();
    binding.setMTOMEnabled(true);

    StoreContentRequest request = objectFactory.createStoreContentRequest();
    request.setName(ClientUtil.TEST_CONTENT_NAME);

    DataHandler dataHandler = new DataHandler(new URLDataSource(ClientUtil.TEST_CONTENT_URL));
    request.setContent(dataHandler);

    StopWatch stopWatch = new StopWatch(this.getClass().getSimpleName());

    stopWatch.start("store");
    StoreContentResponse response = contentStorePort.storeContent(request);
    stopWatch.stop();

    System.out.println(stopWatch.prettyPrint());
}
项目:spring-ws-mtom-example    文件:JaxWsClient.java   
/**
 * Loads the test content from the WebService
 * @throws IOException If an IO error occurs
 */
public void loadContent() throws IOException {
    ContentStoreHttpPortService service = new ContentStoreHttpPortService();
    ContentStoreHttpPort loadContentPort = service.getContentStoreHttpPortSoap11();
    SOAPBinding binding = (SOAPBinding) ((BindingProvider) loadContentPort).getBinding();
    binding.setMTOMEnabled(true);

    LoadContentRequest request = objectFactory.createLoadContentRequest();
    request.setName(ClientUtil.TEST_CONTENT_NAME);
    StopWatch stopWatch = new StopWatch();

    stopWatch.start("load");
    LoadContentResponse response = loadContentPort.loadContent(request);
    stopWatch.stop();

    DataHandler content = response.getContent();
    File outFile = new File(System.getProperty("java.io.tmpdir"), "spring_mtom_jaxws_tmp.bin");

    stopWatch.start("loadAttachmentContent");
    long size = ClientUtil.saveContentToFile(content, outFile);

    System.out.println("Received file size [kB]: " + (size / 1024));
    stopWatch.stop();
    System.out.println(stopWatch.prettyPrint());

}
项目:OLD-OpenJDK8    文件:HandlerConfigurator.java   
void configureHandlers(WSPortInfo port, BindingImpl binding) {
    //Check in cache first
    HandlerAnnotationInfo chain = chainMap.get(port);

    if(chain==null) {
        logGetChain(port);
        // Put it in cache
        chain = handlerModel.getHandlersForPortInfo(port);
        chainMap.put(port,chain);
    }

    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(chain.getRoles());
    }

    logSetChain(port,chain);
    binding.setHandlerChain(chain.getHandlers());
}
项目:OLD-OpenJDK8    文件:DeploymentDescriptorParser.java   
/**
 * Parses the handler and role information and sets it
 * on the {@link WSBinding}.
 *
 * @return true if <handler-chains> element present in DD
 *         false otherwise.
 */
protected boolean setHandlersAndRoles(WSBinding binding, XMLStreamReader reader, QName serviceName, QName portName) {

    if (reader.getEventType() == XMLStreamConstants.END_ELEMENT ||
            !reader.getName().equals(HandlerChainsModel.QNAME_HANDLER_CHAINS)) {
        return false;
    }

    HandlerAnnotationInfo handlerInfo = HandlerChainsModel.parseHandlerFile(
            reader, classLoader, serviceName, portName, binding);

    binding.setHandlerChain(handlerInfo.getHandlers());
    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(handlerInfo.getRoles());
    }

    // move past </handler-chains>
    XMLStreamReaderUtil.nextContent(reader);
    return true;
}
项目:wso2-axis2    文件:ClientMetadataPortTest.java   
/**
 * Validate enabling MTOM when creating the service results ports created under that service
 * have MTOM enabled.
 */
public void testEnableMTOM() {
    QName serviceQName = new QName(namespaceURI, svcLocalPart);
    URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
    DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();
    sparseComposite.setIsMTOMEnabled(true);
    ServiceDelegate.setServiceMetadata(sparseComposite);
    Service service = Service.create(wsdlUrl, serviceQName);
    ClientMetadataPortSEI port = service.getPort(ClientMetadataPortSEI.class);
    assertNotNull(port);
    // Verify that MTOM is enabled on this port.
    BindingProvider bindingProvider = (BindingProvider) port;
    SOAPBinding binding = (SOAPBinding) bindingProvider.getBinding();
    assertTrue(binding.isMTOMEnabled());

    // Verify that specific ports under this service also have MTOM enabled
    QName port1QN = new QName(namespaceURI, multiPortWsdl_portLocalPart1);
    ClientMetadataPortSEI port1 = service.getPort(port1QN, ClientMetadataPortSEI.class);
    SOAPBinding binding1 = ((SOAPBinding) ((BindingProvider) port1).getBinding());
    assertTrue(binding1.isMTOMEnabled());

    QName port2QN = new QName(namespaceURI, multiPortWsdl_portLocalPart2);
    ClientMetadataPortSEI port2 = service.getPort(port2QN, ClientMetadataPortSEI.class);
    SOAPBinding binding2 = ((SOAPBinding) ((BindingProvider) port2).getBinding());
    assertTrue(binding2.isMTOMEnabled());
}
项目:wso2-axis2    文件:BindingProviderTests.java   
/**
 * A test to verify that the Dispatch objects implement the proper interface
 */
public void testDisptachBindingProviderSPI() {
    Service svc = Service.create(serviceQName);
    svc.addPort(portQName, SOAPBinding.SOAP11HTTP_BINDING, "");

    Dispatch dsp = svc.createDispatch(portQName, Source.class, Service.Mode.MESSAGE);

    // Make sure we can cast the object to the right interfaces
    assertTrue("The Dispatch object should also be a javax.xml.ws.BindingProvider", 
            (dsp instanceof javax.xml.ws.BindingProvider));
    assertTrue("The Dispatch object should also be a org.apache.axis2.jaxws.spi.BindingProvider", 
            dsp instanceof org.apache.axis2.jaxws.spi.BindingProvider);

    org.apache.axis2.jaxws.spi.BindingProvider bp = (org.apache.axis2.jaxws.spi.BindingProvider) dsp;

    ServiceDelegate sd = bp.getServiceDelegate();
    assertTrue("The ServiceDescription was null", sd != null);

    EndpointDescription ed = bp.getEndpointDescription();
    assertTrue("The EndpointDescription was null", ed != null);
}
项目:wso2-axis2    文件:DispatchSharedSessionTest.java   
public void testSharedSessionDispatchAsync() {
    Service svc = Service.create(new QName("http://test", "TestService"));
    svc.addPort(new QName("http://test", "TestPort"), SOAPBinding.SOAP11HTTP_BINDING, "http://localhost");
    Dispatch<Source> d = svc.createDispatch(w3cEPR, Source.class, Service.Mode.PAYLOAD);

    d.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
    d.getRequestContext().put(HTTPConstants.COOKIE_STRING, "MyCookie");

    d.invokeAsync(null);

    TestClientInvocationController testController = getInvocationController();
    InvocationContext ic = testController.getInvocationContext();
    testController.invoke(ic);

    assertNotNull("Invocation of the proxy object should have caused COOKIE_STRING keyed property to be on the ServiceContext", ic.getServiceClient().getServiceContext().getProperty(HTTPConstants.HEADER_COOKIE));

}
项目:wso2-axis2    文件:DispatchSharedSessionTest.java   
public void testSharedSessionDispatchAsyncCallback() {
    Service svc = Service.create(new QName("http://test", "TestService"));
    svc.addPort(new QName("http://test", "TestPort"), SOAPBinding.SOAP11HTTP_BINDING, "http://localhost");
    Dispatch<Source> d = svc.createDispatch(w3cEPR, Source.class, Service.Mode.PAYLOAD);

    d.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
    d.getRequestContext().put(HTTPConstants.COOKIE_STRING, "MyCookie");

    d.invokeAsync(null, new DummyAsyncHandler());

    TestClientInvocationController testController = getInvocationController();
    InvocationContext ic = testController.getInvocationContext();
    testController.invoke(ic);

    assertNotNull("Invocation of the proxy object should have caused COOKIE_STRING keyed property to be on the ServiceContext", ic.getServiceClient().getServiceContext().getProperty(HTTPConstants.HEADER_COOKIE));

}
项目:wso2-axis2    文件:DispatchSubmissionAddressingFeatureTest.java   
public void testNoSubmissionAddressingFeature() {
    Service svc = Service.create(new QName("http://test", "TestService"));
    svc.addPort(new QName("http://test", "TestPort"), SOAPBinding.SOAP11HTTP_BINDING, "http://localhost");
    Dispatch<Source> d = svc.createDispatch(subEPR, Source.class, Service.Mode.PAYLOAD);

    d.invoke(null);

    TestClientInvocationController testController = getInvocationController();
    InvocationContext ic = testController.getInvocationContext();
    MessageContext request = ic.getRequestMessageContext();

    String version = (String) request.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
    Boolean disabled = (Boolean) request.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES);
    String required = (String) request.getProperty(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER);

    assertNull(version);
    assertTrue(disabled);
    assertNull(required);

    org.apache.axis2.context.MessageContext axis2Request =
        request.getAxisMessageContext();
    org.apache.axis2.addressing.EndpointReference epr =
        axis2Request.getTo();

    assertNull(epr);
}
项目:wso2-axis2    文件:DispatchSubmissionAddressingFeatureTest.java   
public void testInvalidSubmissionAddressingFeature() {
    // Use the default feature config
    SubmissionAddressingFeature feature = new SubmissionAddressingFeature();

    Service svc = Service.create(new QName("http://test", "TestService"));
    svc.addPort(new QName("http://test", "TestPort"), SOAPBinding.SOAP11HTTP_BINDING, "http://localhost");
    Dispatch<Source> d = svc.createDispatch(w3cEPR, Source.class, Service.Mode.PAYLOAD, feature);

    try {
        d.invoke(null);
        fail("An exception should have been thrown");
    }
    catch (WebServiceException wse) {
        //pass
    }
    catch (Exception e) {
        fail("The wrong exception type was thrown.");
    }
}
项目:wso2-axis2    文件:DispatchOperationResolutionTest.java   
/**
 * Validate that operation resolution does not happen for dynamic ports
 */
public void testDynamicPort_NoResolution() {
    Service service = Service.create(wsdlDocumentLocation, serviceQName);
    QName dynamicPortQN = new QName("http://org/apache/axis2/jaxws/samples/echo/", "DynamicPort");
    service.addPort(dynamicPortQN, SOAPBinding.SOAP11HTTP_BINDING, "http://localhost");
    Dispatch<String> dispatch = service.createDispatch(dynamicPortQN, String.class, Service.Mode.PAYLOAD);

    String result = dispatch.invoke(echoBodyContent_PAYLOAD);

    TestClientInvocationController testController = getInvocationController();
    InvocationContext ic = testController.getInvocationContext();
    MessageContext requestMC = ic.getRequestMessageContext();

    OperationDescription opDesc = requestMC.getOperationDescription();
    assertNull("OpDesc from request MC should be null for dynamic ports", opDesc);
}
项目:wso2-axis2    文件:DispatchAddressingFeatureTest.java   
public void testInvalidAddressingFeature() {
    // Use the default feature config
    AddressingFeature feature = new AddressingFeature();

    Service svc = Service.create(new QName("http://test", "TestService"));
    svc.addPort(new QName("http://test", "TestPort"), SOAPBinding.SOAP11HTTP_BINDING, "http://localhost");
    Dispatch<Source> d = svc.createDispatch(subEPR, Source.class, Service.Mode.PAYLOAD, feature);

    try {
        d.invoke(null);
        fail("An exception should have been thrown");
    }
    catch (WebServiceException wse) {
        //pass
    }
    catch (Exception e) {
        fail("The wrong exception type was thrown.");
    }
}
项目:wso2-axis2    文件:DispatchMTOMFeatureTest.java   
public void testNoMTOMFeature() {
    Service svc = Service.create(new QName("http://test", "TestService"));
    svc.addPort(new QName("http://test", "TestPort"), SOAPBinding.SOAP11HTTP_BINDING, "http://localhost");
    Dispatch<Source> d = svc.createDispatch(new QName("http://test", "TestPort"), Source.class, Service.Mode.PAYLOAD);

    SOAPBinding sb = (SOAPBinding) d.getBinding();
    assertTrue("SOAPBinding should not be null.", sb != null);
    assertTrue("MTOM should not be enabled on the binding by default.", !sb.isMTOMEnabled());

    d.invoke(null);

    TestClientInvocationController testController = getInvocationController();
    InvocationContext ic = testController.getInvocationContext();
    MessageContext request = ic.getRequestMessageContext();

    assertTrue("Request should not be null.", request != null);
    assertFalse("MTOM should not be enabled by default.", request.getMessage().isMTOMEnabled());
}
项目:wso2-axis2    文件:DispatchMTOMFeatureTest.java   
public void testDefaultMTOMFeature() {
    // Use the default feature config
    MTOMFeature feature = new MTOMFeature();

    Service svc = Service.create(new QName("http://test", "TestService"));
    svc.addPort(new QName("http://test", "TestPort"), SOAPBinding.SOAP11HTTP_BINDING, "http://localhost");
    Dispatch<Source> d = svc.createDispatch(new QName("http://test", "TestPort"), 
        Source.class, Service.Mode.PAYLOAD, feature);

    d.invoke(null);

    TestClientInvocationController testController = getInvocationController();
    InvocationContext ic = testController.getInvocationContext();
    MessageContext request = ic.getRequestMessageContext();

    assertTrue("MTOM should be enabled via the MTOMFeature.", request.getMessage().isMTOMEnabled());
}
项目:wso2-axis2    文件:EndpointDescriptionValidator.java   
private static String bindingHumanReadableDescription(String ns) {
    if (SOAPBinding.SOAP11HTTP_BINDING.equals(ns)) {
        return "SOAP 1.1 HTTP Binding";
    } else if (SOAPBinding.SOAP11HTTP_MTOM_BINDING.equals(ns)) {
        return "SOAP 1.1 MTOM HTTP Binding";
    } else if (SOAPBinding.SOAP12HTTP_BINDING.equals(ns)) {
        return "SOAP 1.2 HTTP Binding";
    } else if (SOAPBinding.SOAP12HTTP_MTOM_BINDING.equals(ns)) {
        return "SOAP 1.2 MTOM HTTP Binding";
    } else if (MDQConstants.SOAP11JMS_BINDING.equals(ns)) {
        return "SOAP 1.1 JMS Binding";
    } else if (MDQConstants.SOAP11JMS_MTOM_BINDING.equals(ns)) {
        return "SOAP 1.1 MTOM JMS Binding";
    } else if (MDQConstants.SOAP12JMS_BINDING.equals(ns)) {
        return "SOAP 1.2 JMS Binding";
    } else if (MDQConstants.SOAP12JMS_MTOM_BINDING.equals(ns)) {
        return "SOAP 1.2 MTOM JMS Binding";
    } else if (HTTPBinding.HTTP_BINDING.equals(ns)) {
        return "XML HTTP Binding";
    } else {
        return "Unknown Binding";
    }
}
项目:wso2-axis2    文件:DescriptionUtils.java   
/**
 * Given a binding type value based on WSDL, return the corresponding JAXWS annotation value.
 * The WSDL binding type values are based on the namespace of the binding extension element.
 * The JAXWS annotation values correspond to the values to the HTTPBinding and SOAPBinding
 * annotations.  Additionally, proprietary values for JMS bindings are supported.  The JAXWS
 * binding type annotation values returned could be from SOAPBinding or HTTPBinding.
 * 
 * @param wsdlBindingType The binding type as represnted by the WSDL binding extension namespace
 * @param soapTransport The WSDL transport.  Used to determine if a JMS binding type should
 * be returned
 * @return The binding represented by a JAXWS Binding Type Annotation value from either 
 * SOAPBinding or HTTPBinding.
 */
public static String mapBindingTypeWsdlToAnnotation(String wsdlBindingType, String soapTransport) {
    String soapBindingType = null;
    if (EndpointDescriptionWSDL.SOAP11_WSDL_BINDING.equals(wsdlBindingType)) {
        if (MDQConstants.SOAP11JMS_BINDING.equals(soapTransport)) {
            soapBindingType =  MDQConstants.SOAP11JMS_BINDING;
        } else {
            //REVIEW: We are making the assumption that if not JMS, then HTTP
            soapBindingType = SOAPBinding.SOAP11HTTP_BINDING;
        } 
    } else if (EndpointDescriptionWSDL.SOAP12_WSDL_BINDING.equals(wsdlBindingType)) {
        if (MDQConstants.SOAP12JMS_BINDING.equals(soapTransport)) {
            soapBindingType =  MDQConstants.SOAP12JMS_BINDING;
        } else {
            //REVIEW: We are making the assumption that if not JMS, then HTTP
            soapBindingType = SOAPBinding.SOAP12HTTP_BINDING;
        } 
    } else if (EndpointDescriptionWSDL.HTTP_WSDL_BINDING.equals(wsdlBindingType)) {
        soapBindingType = javax.xml.ws.http.HTTPBinding.HTTP_BINDING;
    }
    return soapBindingType;
}
项目:wso2-axis2    文件:EndpointDescriptionImpl.java   
private boolean validateClientBindingID(String bindingId) {
    boolean isValid = true;
    if (bindingId != null && !(bindingId.equals(SOAPBinding.SOAP11HTTP_BINDING) ||
            bindingId.equals(javax.xml.ws.http.HTTPBinding.HTTP_BINDING) ||
            bindingId.equals(SOAPBinding.SOAP12HTTP_BINDING) ||
            bindingId.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING) ||
            bindingId.equals(SOAPBinding.SOAP12HTTP_MTOM_BINDING) ||
            bindingId.equals(MDQConstants.SOAP11JMS_BINDING) ||
            bindingId.equals(MDQConstants.SOAP12JMS_BINDING) ||
            bindingId.equals(MDQConstants.SOAP11JMS_MTOM_BINDING) ||
            bindingId.equals(MDQConstants.SOAP12JMS_MTOM_BINDING))) {
        throw ExceptionFactory.makeWebServiceException(
                Messages.getMessage("addPortErr0", getPortQName().toString()));
    }
    return isValid;
}
项目:spring-boot-integration-example    文件:JaxWsClient.java   
/**
 * Loads the content with the specified name from the WebService
 * 
 * @param name The name of the content
 * @return The loaded content
 * @throws IOException If an IO error occurs
 */
public DataHandler loadContent(String name) throws IOException {
    ContentStoreHttpPortService service = new ContentStoreHttpPortService();

    service.setHandlerResolver(new HandlerResolver() {
        @Override
        public List<Handler> getHandlerChain(PortInfo portInfo) {
            List<Handler> handlerList = new ArrayList<>();
            handlerList.add(wsSecurityHandler);
            return handlerList;
        }
    });

    ContentStoreHttpPort loadContentPort = service.getContentStoreHttpPortSoap11();
    SOAPBinding binding = (SOAPBinding) ((BindingProvider) loadContentPort).getBinding();
    binding.setMTOMEnabled(true);

    LoadContentRequest request = objectFactory.createLoadContentRequest();
    request.setName(name);
    LoadContentResponse response = loadContentPort.loadContent(request);
    DataHandler content = response.getContent();
    return content;
}
项目:wso2-axis2    文件:JAXWSRIWSDLGenerator.java   
/**
 * This will set up the arguments that will be used by the WsGen tool.
 */
private String[] getWsGenArguments(String className, String bindingType, String localOutputDirectory) throws
        WebServiceException {
    String[] arguments = null;
    if (bindingType == null || bindingType.equals("") || bindingType.equals(
            SOAPBinding.SOAP11HTTP_BINDING) || bindingType.equals(
            SOAPBinding.SOAP11HTTP_MTOM_BINDING)) {
        if (log.isDebugEnabled()) {
            log.debug("Generating WSDL with SOAP 1.1 binding type");
        }
        arguments = new String[]{"-cp", classPath, className, "-keep", "-wsdl:soap1.1", "-d",
                localOutputDirectory};
    } else if (bindingType.equals(SOAPBinding.SOAP12HTTP_BINDING) || bindingType.equals(
            SOAPBinding.SOAP12HTTP_MTOM_BINDING)) {
        if (log.isDebugEnabled()) {
            log.debug("Generating WSDL with SOAP 1.2 binding type");
        }
        arguments = new String[]{"-cp", classPath, className, "-keep", "-extension",
                "-wsdl:Xsoap1.2", "-d", localOutputDirectory};
    } else {
        throw new WebServiceException("The binding " + bindingType + " specified by the " +
                "class " + className + " cannot be used to generate a WSDL. Please choose " +
                "a supported binding type.");
    }
    return arguments;
}
项目:wso2-axis2    文件:BasicAuthSecurityTests.java   
public void testBasicAuth() throws Exception {
    TestLogger.logger.debug("---------------------------------------");
    TestLogger.logger.debug("test: " + getName());

    Dispatch<String> dispatch = getDispatch(Service.Mode.PAYLOAD,
                                            endpointUrl,
                                            SOAPBinding.SOAP11HTTP_BINDING);

    TestLogger.logger.debug(">> Invoking Dispatch<String> BasicAuthSecurityService");
    String retVal = dispatch.invoke(xmlString);
    TestLogger.logger.debug(">> Response [" + retVal + "]");

    assertTrue(retVal != null);

    // Invoke a second time to verify
    retVal = dispatch.invoke(xmlString);
    TestLogger.logger.debug(">> Response [" + retVal + "]");

    assertTrue(retVal != null);
}
项目:wso2-axis2    文件:BasicAuthSecurityTests.java   
public void testBasicAuth_uid_pwd() throws Exception {
      TestLogger.logger.debug("---------------------------------------");
      TestLogger.logger.debug("test: " + getName());

      Dispatch<String> dispatch = getDispatch(Service.Mode.PAYLOAD,
                                            endpointUrl,
                                            SOAPBinding.SOAP11HTTP_BINDING);

      dispatch.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, USER_ID);
dispatch.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, PASSWORD);

      TestLogger.logger.debug(">> Invoking Dispatch<String> BasicAuthSecurityService");
      String retVal = dispatch.invoke(xmlString);
      TestLogger.logger.debug(">> Response [" + retVal + "]");

      assertTrue(retVal != null);

      // Invoke a second time to verify
      TestLogger.logger.debug(">> Invoking Dispatch<String> BasicAuthSecurityService");
      retVal = dispatch.invoke(xmlString);
      TestLogger.logger.debug(">> Response [" + retVal + "]");

      assertTrue(retVal != null);
  }