Java Code Examples for javax.xml.ws.RespectBindingFeature

The following are top voted examples for showing how to use javax.xml.ws.RespectBindingFeature. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: jbossws-cxf   File: JBWS2449TestCase.java   Source Code and License 6 votes vote down vote up
@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
   }
}
 
Example 2
Project: jbossws-cxf   File: JBWS2449TestCase.java   Source Code and License 5 votes vote down vote up
@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);
}
 
Example 3
Project: wso2-axis2   File: RespectBindingConfigurator.java   Source Code and License 5 votes vote down vote up
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.");
    }
}
 
Example 4
Project: wso2-axis2   File: RespectBindingConfigurator.java   Source Code and License 5 votes vote down vote up
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.");
    }
}
 
Example 5
Project: wso2-axis2   File: AddressingProviderTests.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 6
Project: wso2-axis2   File: WSDLBindingsTest.java   Source Code and License 4 votes vote down vote up
/**
 * 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());
    }

}
 
Example 7
Project: wso2-axis2   File: WSDLBindingsTest.java   Source Code and License 4 votes vote down vote up
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());
    }

}
 
Example 8
Project: OpenJSharp   File: Stub.java   Source Code and License 2 votes vote down vote up
/**
 * 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();
    }
}
 
Example 9
Project: openjdk-jdk10   File: Stub.java   Source Code and License 2 votes vote down vote up
/**
 * 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();
    }
}
 
Example 10
Project: openjdk9   File: Stub.java   Source Code and License 2 votes vote down vote up
/**
 * 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();
    }
}
 
Example 11
Project: lookaside_java-1.8.0-openjdk   File: Stub.java   Source Code and License 2 votes vote down vote up
/**
 * 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();
    }
}
 
Example 12
Project: infobip-open-jdk-8   File: Stub.java   Source Code and License 2 votes vote down vote up
/**
 * 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();
    }
}
 
Example 13
Project: OLD-OpenJDK8   File: Stub.java   Source Code and License 2 votes vote down vote up
/**
 * 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();
    }
}
 
Example 14
Project: openjdk-icedtea7   File: Stub.java   Source Code and License 2 votes vote down vote up
/**
 * 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();
    }
}