Example usage for javax.xml.ws.soap SOAPBinding SOAP12HTTP_BINDING

List of usage examples for javax.xml.ws.soap SOAPBinding SOAP12HTTP_BINDING

Introduction

In this page you can find the example usage for javax.xml.ws.soap SOAPBinding SOAP12HTTP_BINDING.

Prototype

String SOAP12HTTP_BINDING

To view the source code for javax.xml.ws.soap SOAPBinding SOAP12HTTP_BINDING.

Click Source Link

Document

A constant representing the identity of the SOAP 1.2 over HTTP binding.

Usage

From source file:eu.domibus.ebms3.sender.MSHDispatcher.java

public SOAPMessage dispatch(final SOAPMessage soapMessage, final String pModeKey) throws EbMS3Exception {

    final QName serviceName = new QName("http://domibus.eu", "msh-dispatch-service");
    final QName portName = new QName("http://domibus.eu", "msh-dispatch");
    final javax.xml.ws.Service service = javax.xml.ws.Service.create(serviceName);
    final String endpoint = pModeProvider.getReceiverParty(pModeKey).getEndpoint();
    service.addPort(portName, SOAPBinding.SOAP12HTTP_BINDING, endpoint);
    Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class,
            javax.xml.ws.Service.Mode.MESSAGE);

    Policy policy = policyFactory
            .parsePolicy(pModeProvider.getLegConfiguration(pModeKey).getSecurity().getPolicy());
    LegConfiguration legConfiguration = pModeProvider.getLegConfiguration(pModeKey);
    dispatch.getRequestContext().put(PolicyConstants.POLICY_OVERRIDE, policy);
    dispatch.getRequestContext().put(ASYMMETRIC_SIG_ALGO_PROPERTY,
            legConfiguration.getSecurity().getSignatureMethod().getAlgorithm());
    dispatch.getRequestContext().put(PMODE_KEY_CONTEXT_PROPERTY, pModeKey);

    TLSClientParameters params = tlsReader.getTlsClientParameters();
    if (params != null && endpoint.startsWith("https://")) {
        Client client = ((DispatchImpl<SOAPMessage>) dispatch).getClient();
        HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
        httpConduit.setTlsClientParameters(params);
    }/* w  w w .  j ava2s  . c  om*/
    SOAPMessage result;
    try {
        result = dispatch.invoke(soapMessage);
    } catch (WebServiceException e) {
        throw new EbMS3Exception(EbMS3Exception.EbMS3ErrorCode.EBMS_0005, null,
                "error dispatching message to " + endpoint, e, MSHRole.SENDING);
    }
    return result;
}

From source file:io.hummer.util.ws.WebServiceClient.java

private void setRelevantAttributes(EndpointReference epr) {
    try {// www.j  a  v a 2s  . com
        this.eprParamsAndProps.addAll(epr.getAllReferenceParameters());
        this.eprParamsAndProps.addAll(epr.getAllReferenceProperties());
        if (this.eprParamsAndProps.size() > 0) {
            if (logger.isDebugEnabled())
                logger.trace("Reference Params/Props: " + this.eprParamsAndProps);
        }

        this.endpointURL = epr.getAddress();
        String binding = SOAPBinding.SOAP11HTTP_BINDING;
        try {
            this.serviceName = epr.getServiceName().getServiceName();
            this.portName = new QName(epr.getPortName());
            service = Service.create(this.serviceName);
            service.addPort(portName, binding, this.endpointURL);
        } catch (Exception e) {
            if (endpointURL.contains("wsdl") || endpointURL.contains("WSDL")) {
                // assume that the given URL is a WSDL URL
                String wsdlURL = endpointURL;
                javax.wsdl.Service wsdlService = getSingleWSDLService(wsdlURL);
                this.serviceName = wsdlService.getQName();
                javax.wsdl.Port port = getDefaultWSDLPort(wsdlService);
                if (port instanceof SOAP12Binding)
                    binding = SOAPBinding.SOAP12HTTP_BINDING;
                this.portName = new QName(serviceName.getNamespaceURI(), port.getName());
                this.endpointURL = getAddressFromWSDLPort(port);
                service = Service.create(new URL(wsdlURL), this.serviceName);
            }
        }
    } catch (WSDLException e) {
        throw new RuntimeException("Unable to create Web service client from WSDL.", e);
    } catch (ConnectException e) {
        throw new RuntimeException("Unable to create Web service client.", e);
    } catch (Exception e) {
        // swallow
        logger.info("Error initializing Web service client.", e);
    }
}

From source file:org.apache.axis2.jaxws.description.builder.JAXWSRIWSDLGenerator.java

/**
 * This will set up the arguments that will be used by the WsGen tool.
 *///www . j a  v  a 2 s.co m
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;
}

From source file:org.apache.axis2.jaxws.description.impl.DescriptionUtils.java

/**
 * Given a binding type value based on a JAXWS anntation, return the corresponding WSDL
 * binding type.  The JAXWS annotation values understood are those returned by
 * mapBindingTypeWsdltoAnnotation.//from   w w w . j a  v a  2s .c o m
 * 
 * @see #mapBindingTypeWsdlToAnnotation(String, String)
 * 
 * @param annotationBindingType The binding type as represented by a JAXWS annotation value
 * @return The binding type as represented by a WSDL binding extension namespace value
 */
public static String mapBindingTypeAnnotationToWsdl(String annotationBindingType) {
    String wsdlBindingType = null;

    if (SOAPBinding.SOAP11HTTP_BINDING.equals(annotationBindingType)
            || MDQConstants.SOAP11JMS_BINDING.equals(annotationBindingType)) {
        wsdlBindingType = EndpointDescriptionWSDL.SOAP11_WSDL_BINDING;
    } else if (SOAPBinding.SOAP12HTTP_BINDING.equals(annotationBindingType)
            || MDQConstants.SOAP12JMS_BINDING.equals(annotationBindingType)) {
        wsdlBindingType = EndpointDescriptionWSDL.SOAP12_WSDL_BINDING;
    } else if (javax.xml.ws.http.HTTPBinding.HTTP_BINDING.equals(annotationBindingType)) {
        wsdlBindingType = EndpointDescriptionWSDL.HTTP_WSDL_BINDING;
    }

    return wsdlBindingType;
}

From source file:org.apache.axis2.jaxws.description.impl.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.
 * //from   w  w w  . jav  a 2 s.c  o m
 * @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;
}

From source file:org.apache.axis2.jaxws.description.impl.EndpointDescriptionImpl.java

private void buildEndpointDescriptionFromAnnotations() {
    // TODO: The comments below are not quite correct; this method is used on BOTH the 
    //       client and server.  On the client the class is always an SEI.  On the server it 
    //       is always a service impl which may be a provider or endpoint based;
    //       endpoint based may reference an SEI class

    // The Service Implementation class could be either Provider-based or Endpoint-based.  The 
    // annotations that are present are similar but different.  Conformance requirements 
    // per JAX-WS
    // - A Provider based implementation MUST carry the @WebServiceProvider annotation
    //   per section 5.1 javax.xml.ws.Provider on page 63
    // - An Endpoint based implementation MUST carry the @WebService annotation per JSR-181 
    //   (reference TBD) and JAX-WS (reference TBD)
    // - An Endpoint based implementation @WebService annotation MAY reference an endpoint
    //   interface 
    // - The @WebService and @WebServiceProvider annotations can not appear in the same class per 
    //   JAX-WS section 7.7 on page 82.

    // If portName was specified, set it.  Otherwise, we will get it from the appropriate
    // annotation when the getter is called.

    // If this is an Endpoint-based service implementation (i.e. not a 
    // Provider-based one), then create the EndpointInterfaceDescription to contain
    // the operations on the endpoint.  Provider-based endpoints don't have operations
    // associated with them, so they don't have an EndpointInterfaceDescription.
    if (webServiceAnnotation != null) {
        // If this impl class references an SEI, then use that SEI to create the EndpointInterfaceDesc.
        String seiClassName = getAnnoWebServiceEndpointInterface();

        if (!composite.isServiceProvider()) {
            Class seiClass = null;
            if (DescriptionUtils.isEmpty(seiClassName)) {
                // This is the client code path; the @WebServce will not have an endpointInterface member
                // For now, just build the EndpointInterfaceDesc based on the class itself.
                seiClass = composite.getCorrespondingClass();
            }//ww w.  j  ava 2  s . co m
            endpointInterfaceDescription = new EndpointInterfaceDescriptionImpl(seiClass, this);
        } else {
            if (DescriptionUtils.isEmpty(getAnnoWebServiceEndpointInterface())) {

                endpointInterfaceDescription = new EndpointInterfaceDescriptionImpl(composite, true, this);

            } else {
                //Otherwise, build the EID based on the SEI composite
                endpointInterfaceDescription = new EndpointInterfaceDescriptionImpl(
                        getServiceDescriptionImpl().getDBCMap().get(seiClassName), false, this);

                // after this is constructed, we need to update the @WebService.name 
                // attribute on the axisService instance
                if (axisService != null) {
                    updateWebServiceNameParameter(
                            ((EndpointInterfaceDescriptionImpl) endpointInterfaceDescription)
                                    .getAnnoWebServiceName(),
                            axisService);
                }
            }
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("WebServiceProvider without WSDL encountered");
        }
        String bindingType = getBindingType();
        if (javax.xml.ws.http.HTTPBinding.HTTP_BINDING.equals(bindingType)
                || SOAPBinding.SOAP11HTTP_BINDING.equals(bindingType)
                || SOAPBinding.SOAP12HTTP_BINDING.equals(bindingType)
                || MDQConstants.SOAP_HTTP_BINDING.equals(bindingType)) {
            endpointInterfaceDescription = new EndpointInterfaceDescriptionImpl(composite, this);
        }
    }
}

From source file:org.apache.axis2.jaxws.description.impl.EndpointDescriptionImpl.java

private void buildAxisServiceFromAnnotations() {
    String serviceName = null;/* w  w w . ja  va 2 s  .  c  om*/
    if (portQName != null) {
        serviceName = createAxisServiceName();
    } else {
        // Make this service name unique.  The Axis2 engine assumes that a service it can not find is a client-side service.
        serviceName = ServiceClient.ANON_SERVICE + this.hashCode() + System.currentTimeMillis();
    }
    axisService = new AxisService(serviceName);

    // Now we have to add an Endpoint to the AxisService instance according to the generated
    // WSDL. Binding type can be SOAP 1.1, SOAP 1.2 or HTTP. Always we have to use the
    // annotated port name as the endpoint name.
    try {
        String bindingType = getBindingType();
        // Default transport protocol is set to HTTP
        String protocol = "http";
        if (bindingType.startsWith(SOAPBinding.SOAP12HTTP_BINDING)) {
            Utils.addSoap12Endpoint(axisService, protocol, getPortQName().getLocalPart());
        } else if (bindingType.startsWith(javax.xml.ws.http.HTTPBinding.HTTP_BINDING)) {
            Utils.addHttpEndpoint(axisService, protocol, getPortQName().getLocalPart());
        } else {
            // Assume SOAP 1.1 over HTTP for all other cases
            Utils.addSoap11Endpoint(axisService, protocol, getPortQName().getLocalPart());
        }
    } catch (Exception e) {
        log.error("Error while generating the Endpoint for service :" + axisService.getName());
    }

}

From source file:org.apache.axis2.jaxws.description.impl.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()));
    }//from   w ww .  ja  v a 2 s .c o  m
    return isValid;
}

From source file:org.apache.axis2.jaxws.description.impl.ServiceDescriptionImpl.java

/**
 * Validate that, if using PAYLOAD mode, then interfaces list cannot contain SOAPMessage or
 * DataSource//from ww  w  . jav  a2 s  .co  m
 *
 * @return
 */
private void validateProviderInterfaces() {

    // Default for ServiceMode is 'PAYLOAD'. So, if it is specified  (explicitly or
    // implicitly) then verify that we are not implementing improper interfaces)
    if ((composite.getServiceModeAnnot() == null)
            || composite.getServiceModeAnnot().value() == javax.xml.ws.Service.Mode.PAYLOAD) {

        Iterator<String> iter = composite.getInterfacesList().iterator();

        while (iter.hasNext()) {
            String interfaceString = iter.next();
            if (interfaceString.equals(MDQConstants.PROVIDER_SOAP)
                    || interfaceString.equals(MDQConstants.PROVIDER_DATASOURCE)) {

                throw ExceptionFactory.makeWebServiceException(
                        Messages.getMessage("validatePIsErr1", composite.getClassName()));
            }
        }

    } else {
        // We are in MESSAGE mode
        // Conformance: JAXWS Spec.- Sec. 4.3 (javax.activation.DataSource)

        // REVIEW: Should the provider interface validation be moved to post-construction validation, 
        // since it seems that the logic to understand the default values for binding type 
        // (see comment below) should be left to the creation of the Description objects.
        String bindingType = null;
        if (composite.getBindingTypeAnnot() != null) {
            bindingType = composite.getBindingTypeAnnot().value();
        }

        Iterator<String> iter = composite.getInterfacesList().iterator();

        while (iter.hasNext()) {
            String interfaceString = iter.next();

            if (interfaceString.equals(MDQConstants.PROVIDER_SOAP)) {

                // Make sure BindingType is SOAP/HTTP with SOAPMessage
                // object, Default for Binding Type is SOAP/HTTP
                if (!DescriptionUtils.isEmpty(bindingType)
                        && !bindingType.equals(SOAPBinding.SOAP11HTTP_BINDING)
                        && !bindingType.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING)
                        && !bindingType.equals(SOAPBinding.SOAP12HTTP_BINDING)
                        && !bindingType.equals(SOAPBinding.SOAP12HTTP_MTOM_BINDING)
                        && !bindingType.equals(MDQConstants.SOAP11JMS_BINDING)
                        && !bindingType.equals(MDQConstants.SOAP11JMS_MTOM_BINDING)
                        && !bindingType.equals(MDQConstants.SOAP12JMS_BINDING)
                        && !bindingType.equals(MDQConstants.SOAP12JMS_MTOM_BINDING)
                        && !bindingType.equals(MDQConstants.SOAP_HTTP_BINDING))

                    throw ExceptionFactory.makeWebServiceException(
                            Messages.getMessage("validatePIsErr2", composite.getClassName()));

            } else if (interfaceString.equals(MDQConstants.PROVIDER_DATASOURCE)) {

                // Make sure BindingType is XML/HTTP with DataSource object
                if (DescriptionUtils.isEmpty(bindingType)
                        || !bindingType.equals(javax.xml.ws.http.HTTPBinding.HTTP_BINDING))

                    throw ExceptionFactory.makeWebServiceException(
                            Messages.getMessage("validatePIsErr3", composite.getClassName()));
            }
        }
    }
}

From source file:org.seedstack.seed.ws.internal.WSPlugin.java

private String getBindingIdForToken(String lexical) { // NOSONAR
    if ("##SOAP11_HTTP".equals(lexical)) {
        return SOAPBinding.SOAP11HTTP_BINDING;
    } else if ("##SOAP11_HTTP_MTOM".equals(lexical)) {
        return SOAPBinding.SOAP11HTTP_MTOM_BINDING;
    } else if ("##SOAP12_HTTP".equals(lexical)) {
        return SOAPBinding.SOAP12HTTP_BINDING;
    } else if ("##SOAP12_HTTP_MTOM".equals(lexical)) {
        return SOAPBinding.SOAP12HTTP_MTOM_BINDING;
    } else if ("##XML_HTTP".equals(lexical)) {
        return HTTPBinding.HTTP_BINDING;
    }//from www.j a v a 2  s .  co  m
    return lexical;
}