Java 类javax.xml.ws.RespectBindingFeature 实例源码

项目:jbossws-cxf    文件:JBWS2449TestCase.java   
@Test
@RunAsClient
public void testWithRespectBinding() throws Exception
{
   URL wsdlURL = new URL(baseURL + "/jaxws-jbws2449?wsdl");
   QName serviceName = new QName("http://org.jboss.ws/jbws2449", "EndpointService");
   try
   {
      Endpoint ep = Service.create(wsdlURL, serviceName).getPort(Endpoint.class, new RespectBindingFeature(true));
      ep.echo("hi");
      fail("Exception expected, the wsdl has a not understood required extensibility element!");
   }
   catch (Exception e)
   {
      //NOOP
   }
}
项目:jbossws-cxf    文件:JBWS2449TestCase.java   
@Test
@RunAsClient
public void testWithRespectBinding2() throws Exception
{
  URL wsdlURL = new URL(baseURL + "/jaxws-jbws2449?wsdl");
   QName serviceName = new QName("http://org.jboss.ws/jbws2449", "EndpointService");
   Endpoint port = Service.create(wsdlURL, serviceName).getPort(Endpoint.class, new RespectBindingFeature(false));
   String retObj = port.echo("Hello");
   assertEquals("Hello", retObj);
}
项目:wso2-axis2    文件:RespectBindingConfigurator.java   
public void configure(MessageContext messageContext, BindingProvider provider) {
    if(log.isDebugEnabled()){
        log.debug("Invoking RespectBindingConfiguration.configure() on client");
    }
    Binding bnd = (Binding) provider.getBinding();
    RespectBindingFeature respectBindingFeature =
        (RespectBindingFeature) bnd.getFeature(RespectBindingFeature.ID);

    if (respectBindingFeature == null) {
        throw ExceptionFactory.makeWebServiceException(
             Messages.getMessage("respectBindingNotSpecified"));
    }
    boolean isEnabled = respectBindingFeature.isEnabled();
    if(isEnabled){
        if(bnd instanceof SOAPBinding){
            ((SOAPBinding)bnd).setRespectBindingEnabled(isEnabled);
        }
        //Get the wsdl document location, if wsdl is not found throw a WebservicesException.
        //If wsdl is found, look for wsdl extensions.
        EndpointDescription endpointDescription = provider.getEndpointDescription();
        endpointDescription.setRespectBinding(isEnabled);
        WSDLExtensionUtils.processExtensions(endpointDescription);

        //We have build up set of extensions from wsdl
        //let go ahead and validate these extensions now.
        EndpointDescriptionValidator endpointValidator = new EndpointDescriptionValidator(endpointDescription);

        boolean isEndpointValid = endpointValidator.validate(true);
        //throw Exception if extensions are not understood by Engine.
        if (!isEndpointValid) {
            String msg = Messages.getMessage("endpointDescriptionValidationErrors",
                                             endpointValidator.toString());
            throw ExceptionFactory.makeWebServiceException(msg);
        }
    }
    if(log.isDebugEnabled()){
        log.debug("Exit from RespectBindingConfiguration.configure() on client.");
    }
}
项目:wso2-axis2    文件:RespectBindingConfigurator.java   
public void configure(EndpointDescription endpointDescription) {
    if(log.isDebugEnabled()){
        log.debug("Invoking RespectBindingConfiguration.configure() on Server");
    }
    RespectBinding annotation =
        (RespectBinding) ((EndpointDescriptionJava) endpointDescription).getAnnoFeature(RespectBindingFeature.ID);

    if (annotation != null) {
        if (log.isDebugEnabled()) {
            log.debug("Setting respectBinding to " + annotation.enabled());
        }
        endpointDescription.setRespectBinding(annotation.enabled());

        // Once we know that @RespectBinding is enabled, we have to find
        // any binding extensibility elements available and see which ones
        // have the "required" flag set to true.
        EndpointDescriptionWSDL edw = (EndpointDescriptionWSDL) endpointDescription;
        Binding bnd = edw.getWSDLBinding();
        Set<WSDLValidatorElement> requiredExtension = endpointDescription.getRequiredBindings();
        List<QName> unusedExtensions = new ArrayList<QName>();
        //invoke the search algorithm.
        WSDLExtensionUtils.search(bnd, requiredExtension, unusedExtensions);

        if (log.isDebugEnabled()) {
            log.debug("The following extensibility elements were found, but were not required.");
            for (int n = 0; n < unusedExtensions.size(); ++n)
                log.debug("[" + (n + 1) + "] - " + unusedExtensions.get(n));
        }
    }
    else {
        if (log.isDebugEnabled()) {
            log.debug("No @RespectBinding annotation was found.");
        }
    }
    if(log.isDebugEnabled()){
        log.debug("Exit from RespectBindingConfiguration.configure() on Server.");
    }
}
项目:wso2-axis2    文件:AddressingProviderTests.java   
private Dispatch<SOAPMessage> createDispatchWithRespectBinding() throws Exception {
    URL wsdlURL = getWsdl();
    assertNotNull(wsdlURL);
    Service svc = Service.create(wsdlURL, serviceName);

    WebServiceFeature[] wsf = {new AddressingFeature(true), new RespectBindingFeature(true)};

    Dispatch<SOAPMessage> dispatch =
        svc.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE, wsf);

    return dispatch;
}
项目:wso2-axis2    文件:WSDLBindingsTest.java   
/**
 * This test does the following
 * 1) Defines RespectBindingAnnotation with enabled=true
 * 2) Fakes creation of an EndpointDescription with RespectBinding
 * 3) Invokes RespectBindingConfigurator.
 * 4) Checks for all Extensibility Element definition in wsdl:binding .
 * 5) fails if it does not find expected elements in bindings.
 */

public void testExtenisbilityElementAtBinding() throws Exception{
    QName serviceQName = new QName(namespaceURI, serviceName);
    URL wsdlUrl = getWsdlURL(wsdl);
    assertNotNull(wsdl);

    DescriptionBuilderComposite serviceDBC = new DescriptionBuilderComposite();

    Map<String, List<Annotation>> map = new HashMap<String, List<Annotation>>();
    ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();

    RespectBindingAnnot wsFeature = new RespectBindingAnnot();
    // Define RespectBinding and set as enabled
    wsFeature.setEnabled(true);
    wsFeatures.add(wsFeature);

    map.put(AddNumbersPortTypeSEI.class.getName(), wsFeatures);
    serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map);       
    ServiceDelegate.setServiceMetadata(serviceDBC);
    try{
        //create service with wsdlurl.
        Service service = Service.create(wsdlUrl, serviceQName);
        assertNotNull("Service is null",service);

        //Fetch Service Delegate so we can read EndpointDescription.
        ServiceDelegate sd = getDelegate(service);
        assertNotNull("ServiceDelegate is null", sd);

        ServiceDescription serviceDesc = sd.getServiceDescription();
        assertNotNull("ServiceDescription is null", serviceDesc);

        //Create EndpointDescription
        DescriptionFactory.updateEndpoint(serviceDesc, AddNumbersPortTypeSEI.class, new QName(namespaceURI, portName), UpdateType.GET_PORT);

        //Read EndpointDescription
        EndpointDescription ed = serviceDesc.getEndpointDescription(new QName(namespaceURI, portName));
        assertNotNull("EndpointDescription is null", ed);

        //Use RespectBindingConfigurator to read extensibility element in wsdlBindings.
        RespectBindingConfigurator rbc = new RespectBindingConfigurator();
        //Mock Object Server Framework.
        ServerFramework sf = new ServerFramework();
        Annotation a = wsFeature;
        sf.addConfigurator(RespectBindingFeature.ID, rbc);
        sf.addAnnotation(a);
        //lets hang the RespectBinding annotation to the EndpointDefinition
        addAnnotation(ed, sf);           
        rbc.configure(ed);
        Set<WSDLValidatorElement> elements = ed.getRequiredBindings();
        assertNotNull("Set of WSDLValidatorElement was null", elements);
        assertEquals("Expecting 5 Extension elements from wsdl in Set of WSDLValidatorElements but found "+elements.size(),elements.size(), 5);

    }catch(Exception e){
        e.printStackTrace();
        fail(e.getMessage());
    }

}
项目:wso2-axis2    文件:WSDLBindingsTest.java   
public void testPolicySetSample() throws Exception{
    QName serviceQName = new QName(policySampleURI, policyServiceName);
    URL wsdlUrl = getWsdlURL(policySample);
    assertNotNull(policySample);

   DescriptionBuilderComposite serviceDBC = new DescriptionBuilderComposite();

    Map<String, List<Annotation>> map = new HashMap<String, List<Annotation>>();
    ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();

    RespectBindingAnnot wsFeature = new RespectBindingAnnot();
    // Define RespectBinding and set as enabled
    wsFeature.setEnabled(true);
    wsFeatures.add(wsFeature);

    map.put(StockQuoteSEI.class.getName(), wsFeatures);
    serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map);       
    ServiceDelegate.setServiceMetadata(serviceDBC);
    try{
        //create service with wsdlurl.
        Service service = Service.create(wsdlUrl, serviceQName);
        assertNotNull("Service is null",service);

        //Fetch Service Delegate so we can read EndpointDescription.
        ServiceDelegate sd = getDelegate(service);
        assertNotNull("ServiceDelegate is null", sd);

        ServiceDescription serviceDesc = sd.getServiceDescription();
        assertNotNull("ServiceDescription is null", serviceDesc);

        QName name = new QName(policySampleURI, policyPortName);
        //Create EndpointDescription
        DescriptionFactory.updateEndpoint(serviceDesc, StockQuoteSEI.class, name, UpdateType.GET_PORT);

        //Read EndpointDescription
        EndpointDescription ed = serviceDesc.getEndpointDescription(name);
        assertNotNull("EndpointDescription is null", ed);

        //Use RespectBindingConfigurator to read extensibility element in wsdlBindings.
        RespectBindingConfigurator rbc = new RespectBindingConfigurator();
        //Mock Object Server Framework.
        ServerFramework sf = new ServerFramework();
        Annotation a = wsFeature;
        sf.addConfigurator(RespectBindingFeature.ID, rbc);
        sf.addAnnotation(a);
        //lets hang the RespectBinding annotation to the EndpointDefinition
        addAnnotation(ed, sf);           
        rbc.configure(ed);
        Set<WSDLValidatorElement> elements = ed.getRequiredBindings();
        assertNotNull("Set of WSDLValidatorElement was null", elements);
        assertEquals("Expecting 4 Extension elements from wsdl in Set of WSDLValidatorElements but found "+elements.size(),elements.size(), 4);
    }catch(Exception e){
        e.printStackTrace();
        fail(e.getMessage());
    }

}
项目:OpenJSharp    文件:Stub.java   
/**
 * Checks only if RespectBindingFeature is enabled
 * checks if all required wsdl extensions in the
 * corresponding wsdl:Port are understood when RespectBindingFeature is enabled.
 * @throws WebServiceException
 *      when any wsdl extension that has wsdl:required=true is not understood
 */
private static void checkAllWSDLExtensionsUnderstood(WSPortInfo port, WSBinding binding) {
    if (port.getPort() != null && binding.isFeatureEnabled(RespectBindingFeature.class)) {
        port.getPort().areRequiredExtensionsUnderstood();
    }
}
项目:openjdk-jdk10    文件:Stub.java   
/**
 * Checks only if RespectBindingFeature is enabled
 * checks if all required wsdl extensions in the
 * corresponding wsdl:Port are understood when RespectBindingFeature is enabled.
 * @throws WebServiceException
 *      when any wsdl extension that has wsdl:required=true is not understood
 */
private static void checkAllWSDLExtensionsUnderstood(WSPortInfo port, WSBinding binding) {
    if (port.getPort() != null && binding.isFeatureEnabled(RespectBindingFeature.class)) {
        port.getPort().areRequiredExtensionsUnderstood();
    }
}
项目:openjdk9    文件:Stub.java   
/**
 * Checks only if RespectBindingFeature is enabled
 * checks if all required wsdl extensions in the
 * corresponding wsdl:Port are understood when RespectBindingFeature is enabled.
 * @throws WebServiceException
 *      when any wsdl extension that has wsdl:required=true is not understood
 */
private static void checkAllWSDLExtensionsUnderstood(WSPortInfo port, WSBinding binding) {
    if (port.getPort() != null && binding.isFeatureEnabled(RespectBindingFeature.class)) {
        port.getPort().areRequiredExtensionsUnderstood();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Stub.java   
/**
 * Checks only if RespectBindingFeature is enabled
 * checks if all required wsdl extensions in the
 * corresponding wsdl:Port are understood when RespectBindingFeature is enabled.
 * @throws WebServiceException
 *      when any wsdl extension that has wsdl:required=true is not understood
 */
private static void checkAllWSDLExtensionsUnderstood(WSPortInfo port, WSBinding binding) {
    if (port.getPort() != null && binding.isFeatureEnabled(RespectBindingFeature.class)) {
        port.getPort().areRequiredExtensionsUnderstood();
    }
}
项目:infobip-open-jdk-8    文件:Stub.java   
/**
 * Checks only if RespectBindingFeature is enabled
 * checks if all required wsdl extensions in the
 * corresponding wsdl:Port are understood when RespectBindingFeature is enabled.
 * @throws WebServiceException
 *      when any wsdl extension that has wsdl:required=true is not understood
 */
private static void checkAllWSDLExtensionsUnderstood(WSPortInfo port, WSBinding binding) {
    if (port.getPort() != null && binding.isFeatureEnabled(RespectBindingFeature.class)) {
        port.getPort().areRequiredExtensionsUnderstood();
    }
}
项目:OLD-OpenJDK8    文件:Stub.java   
/**
 * Checks only if RespectBindingFeature is enabled
 * checks if all required wsdl extensions in the
 * corresponding wsdl:Port are understood when RespectBindingFeature is enabled.
 * @throws WebServiceException
 *      when any wsdl extension that has wsdl:required=true is not understood
 */
private static void checkAllWSDLExtensionsUnderstood(WSPortInfo port, WSBinding binding) {
    if (port.getPort() != null && binding.isFeatureEnabled(RespectBindingFeature.class)) {
        port.getPort().areRequiredExtensionsUnderstood();
    }
}
项目:openjdk-icedtea7    文件:Stub.java   
/**
 * Checks only if RespectBindingFeature is enabled
 * checks if all required wsdl extensions in the
 * corresponding wsdl:Port are understood when RespectBindingFeature is enabled.
 * @throws WebServiceException
 *      when any wsdl extension that has wsdl:required=true is not understood
 */
private static void checkAllWSDLExtensionsUnderstood(WSPortInfo port, WSBinding binding) {
    if (port.getPort() != null && binding.isFeatureEnabled(RespectBindingFeature.class)) {
        ((WSDLPortImpl) port.getPort()).areRequiredExtensionsUnderstood();
    }
}