Java 类javax.xml.ws.soap.AddressingFeature.Responses 实例源码

项目:wso2-axis2    文件:ClientMetadataAddressingFeatureTests.java   
/**
 * Create a service as would be done via injection or lookup, including a sparse composite that 
 * contains features (as might be set by a deployment descriptor).
 * 
 * @return a Service created as done via injection or lookup.
 */
private Service createService() {
    // Even for a port injection or lookup, the service will also be treated as an injection or lookup
    // So we need to setup the sparse DBC to create the service
    QName serviceQName = new QName(namespaceURI, svcLocalPart);
    URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
    DescriptionBuilderComposite serviceDBC = new DescriptionBuilderComposite();

    Map<String, List<Annotation>> map = new HashMap();
    ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();
    AddressingAnnot addressingFeature = new AddressingAnnot();
    addressingFeature.setEnabled(true);
    addressingFeature.setRequired(true);
    addressingFeature.setResponses(Responses.NON_ANONYMOUS);
    wsFeatures.add(addressingFeature);
    map.put(ClientMetadataAddressingPortSEI.class.getName(), wsFeatures);
    serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map);
    ServiceDelegate.setServiceMetadata(serviceDBC);
    Service service = Service.create(wsdlUrl, serviceQName);
    return service;
}
项目:wso2-axis2    文件:AddressingConfigurator.java   
/**
 * Given a value for the Addressing.responses annotation attribute, map it to the corresponding
 * Addressing constant to be set on the AxisSservice
 * 
 * @param responses Enum value from the Addressing.responses annotation attribute
 * @return String from AddressingContstants corresponding to the responses value.
 */
static public String mapResponseAttributeToAddressing(Responses responses) {
    String addressingType = null;
    switch (responses) {
        case ALL:
            addressingType = AddressingConstants.WSAM_INVOCATION_PATTERN_BOTH;
            break;
        case ANONYMOUS:
            addressingType = AddressingConstants.WSAM_INVOCATION_PATTERN_SYNCHRONOUS;
            break;
        case NON_ANONYMOUS:
            addressingType = AddressingConstants.WSAM_INVOCATION_PATTERN_ASYNCHRONOUS;
            break;
    }
    return addressingType;
}
项目:wso2-axis2    文件:ServiceDescriptionImpl.java   
public Responses getAddressingResponses(Object serviceDelegateKey, Class seiClass) {
    Responses responses = null;
    List<Annotation> seiFeatureList = getSEIFeatureList(serviceDelegateKey, seiClass);
    if (log.isDebugEnabled()) {
        log.debug("Feature list for delegate: " + serviceDelegateKey + ", and SEI: " + seiClass
                + ", is: " + seiFeatureList);
    }
    if (seiFeatureList != null) {
        for (int i = 0; i < seiFeatureList.size(); i++) {
            Annotation checkAnnotation = seiFeatureList.get(i);
            if (checkAnnotation instanceof AddressingAnnot) {
                AddressingAnnot addressingAnnot = (AddressingAnnot) checkAnnotation;
                responses = addressingAnnot.responses();
            }
        }
    }
    return responses;
}
项目:wso2-axis2    文件:ClientMetadataAddressingFeatureTests.java   
public void testAddressingResponses() {
    Service service = createService();
    ClientMetadataAddressingPortSEI port = service.getPort(ClientMetadataAddressingPortSEI.class);

    BindingProvider bindingProvider = (BindingProvider) port;
    SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding();
    assertTrue("Addressing is not configured", soapBinding.isAddressingConfigured());
    assertEquals("Addressing Responses incorrect", Responses.NON_ANONYMOUS, soapBinding.getAddressingResponses());
}
项目:wso2-axis2    文件:ClientMetadataAddressingFeatureTests.java   
public void testDefaultAddressingValues() {
    QName serviceQName = new QName(namespaceURI, svcLocalPart);
    URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
    DescriptionBuilderComposite serviceDBC = new DescriptionBuilderComposite();

    Service service = Service.create(wsdlUrl, serviceQName);
    ClientMetadataAddressingPortSEI port = service.getPort(ClientMetadataAddressingPortSEI.class);

    BindingProvider bindingProvider = (BindingProvider) port;
    SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding();
    assertFalse("Addressing is configured", soapBinding.isAddressingConfigured());
    assertFalse("Addressing is enabled", soapBinding.isAddressingEnabled());
    assertFalse("Addressing is required", soapBinding.isAddressingRequired());
    assertEquals("Addressing responses incorrect", Responses.ALL, soapBinding.getAddressingResponses());
}
项目:wso2-axis2    文件:SOAPBinding.java   
public void setAddressingResponses(Responses responses) {
    addressingResponses = responses;
}
项目:wso2-axis2    文件:BindingProvider.java   
/**
 * Configure the binding from the Metadata for WebService Features.
 */
private void configureBindingFromMetadata() {
    // MTOM can be enabled either at the ServiceDescription level (via the WSDL binding type) or
    // at the EndpointDescription level via the binding type used to create a Dispatch.
    boolean enableMTOMFromMetadata = false;
    int mtomThreshold = 0;
    boolean isAddressingConfiguredViaMetadata = false;
    boolean enableRespectBindingdFromMetadata = false;
    boolean enableAddressingFromMetadata = false;
    boolean requireAddressingFromMetadata = false;
    Responses addressingResponses = null;

    // if we have an SEI for the port, then we'll use it in order to search for WebService Feature configuration
    if(endpointDesc.getEndpointInterfaceDescription() != null
            &&
            endpointDesc.getEndpointInterfaceDescription().getSEIClass() != null) {
        enableMTOMFromMetadata = endpointDesc.getServiceDescription().isMTOMEnabled(serviceDelegate, 
                                                           endpointDesc.getEndpointInterfaceDescription().getSEIClass());
        mtomThreshold = getMTOMThreshold(endpointDesc.getServiceDescription(), serviceDelegate,
                endpointDesc.getEndpointInterfaceDescription().getSEIClass());

        enableRespectBindingdFromMetadata = isRespectBindingEnabled(endpointDesc.getServiceDescription(), serviceDelegate,
                endpointDesc.getEndpointInterfaceDescription().getSEIClass());

        isAddressingConfiguredViaMetadata = isAddressingConfigured(endpointDesc.getServiceDescription(), serviceDelegate,
                endpointDesc.getEndpointInterfaceDescription().getSEIClass());
        if (isAddressingConfiguredViaMetadata) {
            enableAddressingFromMetadata = isAddressingEnabled(endpointDesc.getServiceDescription(), serviceDelegate,
                    endpointDesc.getEndpointInterfaceDescription().getSEIClass());
            requireAddressingFromMetadata = isAddressingRequired(endpointDesc.getServiceDescription(), serviceDelegate,
                    endpointDesc.getEndpointInterfaceDescription().getSEIClass());
            addressingResponses = getAddressingResponses(endpointDesc.getServiceDescription(), serviceDelegate,
                    endpointDesc.getEndpointInterfaceDescription().getSEIClass());
        }


    }
    else {
        enableMTOMFromMetadata = endpointDesc.getServiceDescription().isMTOMEnabled(serviceDelegate);
        // MTOM.Threshold, RespectBinding, and Addressing does not need to be set here based on the sparse composite 
        // (i.e. depolyment descriptor) since it can only be applied to a port injection (i.e. an SEI) using a DD.
    }
    if (!enableMTOMFromMetadata) {
        String bindingType = endpointDesc.getClientBindingID();
        enableMTOMFromMetadata = (bindingType.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING) || 
                                  bindingType.equals(SOAPBinding.SOAP12HTTP_MTOM_BINDING));
    }

    if (enableMTOMFromMetadata) {
        ((SOAPBinding) binding).setMTOMEnabled(true);
        ((SOAPBinding) binding).setMTOMThreshold(mtomThreshold);
    }

    if (enableRespectBindingdFromMetadata) {
        ((SOAPBinding) binding).setRespectBindingEnabled(true);
    }

    if (isAddressingConfiguredViaMetadata) {
        ((SOAPBinding) binding).setAddressingConfigured(true);
        ((SOAPBinding) binding).setAddressingEnabled(enableAddressingFromMetadata);
        ((SOAPBinding) binding).setAddressingRequired(requireAddressingFromMetadata);
        ((SOAPBinding) binding).setAddressingResponses(addressingResponses);
    }
}
项目:wso2-axis2    文件:BindingProvider.java   
private Responses getAddressingResponses(ServiceDescription serviceDescription, ServiceDelegate serviceDelegateKey, 
        Class seiClass) {
    Responses responses = serviceDescription.getAddressingResponses(serviceDelegateKey, seiClass);
    return responses;
}
项目:wso2-axis2    文件:ProxyAddressingMetadataTest.java   
/**
 * Validate correct behavior when addressing-related metadata is specified in a sparse composite, such as
 * would be used to represent configuration via a Deployment Descriptor.
 */
public void testAddressingMetadata() {
    Map<String, List<Annotation>> map = new HashMap();
    ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();
    AddressingAnnot addressingFeature = new AddressingAnnot();
    addressingFeature.setEnabled(true);
    addressingFeature.setRequired(true);
    addressingFeature.setResponses(Responses.NON_ANONYMOUS);
    wsFeatures.add(addressingFeature);
    map.put(ProxyAddressingService.class.getName(), wsFeatures);
    DescriptionBuilderComposite serviceDBC = new DescriptionBuilderComposite();
    serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map);
    ServiceDelegate.setServiceMetadata(serviceDBC);

    Service svc = Service.create(new QName("http://test", "ProxyAddressingService"));
    ProxyAddressingService proxy = svc.getPort(ProxyAddressingService.class);
    assertNotNull(proxy);

    proxy.doSomething("12345");

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

    String version = (String) request.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
    assertNotNull("Version not set", version);
    assertEquals("Wrong addressing version", Final.WSA_NAMESPACE, version);

    String required = (String) request.getProperty(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER);
    assertNotNull("Required not set", required);
    assertEquals("Wrong addressing required", AddressingConstants.ADDRESSING_REQUIRED, required);


    Boolean disabled = (Boolean) request.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES);
    assertNotNull("Disabled not set", disabled);
    assertFalse("Addressing disabled", disabled);

    String responses = (String) request.getProperty(AddressingConstants.WSAM_INVOCATION_PATTERN_PARAMETER_NAME);
    assertNotNull("Responses not set", responses);
    assertEquals("Wrong responses value", AddressingConstants.WSAM_INVOCATION_PATTERN_ASYNCHRONOUS, responses);

}
项目:wso2-axis2    文件:ProxyAddressingMetadataTest.java   
/**
 * Validate correct behavior when addressing is disabled via addressing-related metadata specified in a sparse composite, such as
 * would be used to represent configuration via a Deployment Descriptor.
 */
public void testAddressingMetadataDisabled() {
    Map<String, List<Annotation>> map = new HashMap();
    ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();
    AddressingAnnot addressingFeature = new AddressingAnnot();
    addressingFeature.setEnabled(false);
    addressingFeature.setRequired(true);
    addressingFeature.setResponses(Responses.NON_ANONYMOUS);
    wsFeatures.add(addressingFeature);
    map.put(ProxyAddressingService.class.getName(), wsFeatures);
    DescriptionBuilderComposite serviceDBC = new DescriptionBuilderComposite();
    serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map);
    ServiceDelegate.setServiceMetadata(serviceDBC);

    Service svc = Service.create(new QName("http://test", "ProxyAddressingService"));
    ProxyAddressingService proxy = svc.getPort(ProxyAddressingService.class);
    assertNotNull(proxy);

    proxy.doSomething("12345");

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

    // If addressing is not enabled the version should not be set
    String version = (String) request.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
    assertNull("Version set", version);

    Boolean disabled = (Boolean) request.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES);
    assertNotNull("Disabled not set", disabled);
    assertTrue("Addressing disabled", disabled);

    // Even though required=true above, per the addressing developers, they want to leave it set as unspecified when
    // addressing is not enabled.
    String required = (String) request.getProperty(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER);
    assertNotNull("Required not set", required);
    assertEquals("Wrong addressing required", AddressingConstants.ADDRESSING_UNSPECIFIED, required);

    String responses = (String) request.getProperty(AddressingConstants.WSAM_INVOCATION_PATTERN_PARAMETER_NAME);
    assertNotNull("Responses not set", responses);
    assertEquals("Wrong responses value", AddressingConstants.WSAM_INVOCATION_PATTERN_ASYNCHRONOUS, responses);

}
项目:wso2-axis2    文件:SOAPBinding.java   
/**
 * Return the type of responses required by Addressing.
 * Note that if addressing was not explicitly configured via metadata, this will return a default value.
 * @see #isAddressingConfigured()
 * @return AddressingFeature.Responses ENUM value indicating what type of addressing responses are required. 
 */
public Responses getAddressingResponses() {
    return addressingResponses;
}
项目:wso2-axis2    文件:ServiceDescription.java   
/**
 * Answer the type of Addressing responses required by the service-requester.
 * Note that if addressing was not configured via metadata, then this method will return a default value,
 * otherwise it will return the value configured via metadata.
 * @see #isAddressingConfigured(Object, Class)
 * @param serviceDelegateKey The instance of the service delegate related to this service
 * @param seiClass The SEI for the port to retrieve the setting for.
 * @return AddressingFeature.Responses vale corresponding to the type of responses required by service-requester. 
 */
public abstract Responses getAddressingResponses(Object serviceDelegateKey, Class seiClass);