Search in sources :

Example 61 with Service

use of javax.xml.ws.Service in project wildfly by wildfly.

the class XercesUsageInWebServiceTestCase method testXercesUsageInWebService.

/**
     * Test that the webservice invocation works fine
     *
     * @throws Exception
     */
@OperateOnDeployment("webservice-app-with-xerces")
@Test
public void testXercesUsageInWebService() throws Exception {
    final QName serviceName = new QName("org.jboss.as.test.integration.xerces.ws", "XercesUsageWebService");
    final URL wsdlURL = new URL(url.toExternalForm() + "XercesUsageWebService?wsdl");
    final Service service = Service.create(wsdlURL, serviceName);
    final XercesUsageWSEndpoint port = service.getPort(XercesUsageWSEndpoint.class);
    final String xml = "dummy.xml";
    final String result = port.parseUsingXerces(xml);
    Assert.assertEquals("Unexpected return message from webservice", XercesUsageWebService.SUCCESS_MESSAGE, result);
}
Also used : QName(javax.xml.namespace.QName) XercesUsageWebService(org.jboss.as.test.integration.xerces.ws.XercesUsageWebService) Service(javax.xml.ws.Service) XercesUsageWSEndpoint(org.jboss.as.test.integration.xerces.ws.XercesUsageWSEndpoint) URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 62 with Service

use of javax.xml.ws.Service in project tomee by apache.

the class WsFactory method getObjectInstance.

public Object getObjectInstance(final Object object, final Name name, final Context context, final Hashtable environment) throws Exception {
    // ignore non resource-refs
    if (!(object instanceof ResourceRef)) {
        return null;
    }
    final Reference ref = (Reference) object;
    final Object value;
    if (NamingUtil.getProperty(ref, NamingUtil.JNDI_NAME) != null) {
        // lookup the value in JNDI
        value = super.getObjectInstance(object, name, context, environment);
    } else {
        // load service class which is used to construct the port
        final String serviceClassName = NamingUtil.getProperty(ref, NamingUtil.WS_CLASS);
        Class<? extends Service> serviceClass = Service.class;
        if (serviceClassName != null) {
            serviceClass = NamingUtil.loadClass(serviceClassName).asSubclass(Service.class);
            if (serviceClass == null) {
                throw new NamingException("Could not load service type class " + serviceClassName);
            }
        }
        // load the reference class which is the ultimate type of the port
        final Class<?> referenceClass = NamingUtil.loadClass(ref.getClassName());
        // if ref class is a subclass of Service, use it for the service class
        if (referenceClass != null && Service.class.isAssignableFrom(referenceClass)) {
            serviceClass = referenceClass.asSubclass(Service.class);
        }
        // PORT ID
        final String serviceId = NamingUtil.getProperty(ref, NamingUtil.WS_ID);
        // Service QName
        QName serviceQName = null;
        if (NamingUtil.getProperty(ref, NamingUtil.WS_QNAME) != null) {
            serviceQName = QName.valueOf(NamingUtil.getProperty(ref, NamingUtil.WS_QNAME));
        }
        // WSDL URL
        URL wsdlUrl = null;
        if (NamingUtil.getProperty(ref, NamingUtil.WSDL_URL) != null) {
            wsdlUrl = new URL(NamingUtil.getProperty(ref, NamingUtil.WSDL_URL));
        }
        // Port QName
        QName portQName = null;
        if (NamingUtil.getProperty(ref, NamingUtil.WS_PORT_QNAME) != null) {
            portQName = QName.valueOf(NamingUtil.getProperty(ref, NamingUtil.WS_PORT_QNAME));
        }
        // port refs
        List<PortRefData> portRefs = NamingUtil.getStaticValue(ref, "port-refs");
        if (portRefs == null) {
            portRefs = Collections.emptyList();
        }
        // HandlerChain
        List<HandlerChainData> handlerChains = NamingUtil.getStaticValue(ref, "handler-chains");
        if (handlerChains == null) {
            handlerChains = Collections.emptyList();
        }
        Collection<Injection> injections = NamingUtil.getStaticValue(ref, "injections");
        if (injections == null) {
            injections = Collections.emptyList();
        }
        final Properties properties = new Properties();
        properties.putAll(environment);
        final JaxWsServiceReference serviceReference = new JaxWsServiceReference(serviceId, serviceQName, serviceClass, portQName, referenceClass, wsdlUrl, portRefs, handlerChains, injections, properties);
        value = serviceReference.getObject();
    }
    return value;
}
Also used : HandlerChainData(org.apache.openejb.core.webservices.HandlerChainData) Reference(javax.naming.Reference) JaxWsServiceReference(org.apache.openejb.core.ivm.naming.JaxWsServiceReference) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) Injection(org.apache.openejb.Injection) Properties(java.util.Properties) URL(java.net.URL) JaxWsServiceReference(org.apache.openejb.core.ivm.naming.JaxWsServiceReference) ResourceRef(org.apache.naming.ResourceRef) NamingException(javax.naming.NamingException) PortRefData(org.apache.openejb.core.webservices.PortRefData)

Example 63 with Service

use of javax.xml.ws.Service in project ddf by codice.

the class TestAttributeQueryClaimsHandler method setUp.

@Before
public void setUp() throws IOException {
    signatureProperties = mock(Object.class);
    encryptionProperties = mock(Object.class);
    service = mock(Service.class);
    dispatch = (Dispatch<StreamSource>) mock(Dispatch.class);
    encryptionService = mock(EncryptionService.class);
    systemCrypto = new SystemCrypto("encryption.properties", "signature.properties", encryptionService);
    simpleSign = new SimpleSign(systemCrypto);
    supportedClaims = new ArrayList<>();
    supportedClaims.add("Role");
    supportedClaims.add("NameIdentifier");
    supportedClaims.add("Email");
    AttributeQueryClaimsHandlerTest attributeQueryClaimsHandler = new AttributeQueryClaimsHandlerTest();
    spyAttributeQueryClaimsHandler = spy(attributeQueryClaimsHandler);
    spyAttributeQueryClaimsHandler.setWsdlLocation("wsdlLocation");
    spyAttributeQueryClaimsHandler.setServiceName("serviceName");
    spyAttributeQueryClaimsHandler.setPortName("portName");
    spyAttributeQueryClaimsHandler.setSimpleSign(simpleSign);
    spyAttributeQueryClaimsHandler.setSupportedClaims(supportedClaims);
    spyAttributeQueryClaimsHandler.setExternalAttributeStoreUrl(EXTERNAL_ATTRIBUTE_STORE);
    spyAttributeQueryClaimsHandler.setIssuer(ISSUER);
    spyAttributeQueryClaimsHandler.setDestination(DESTINATION);
    spyAttributeQueryClaimsHandler.setAttributeMapLocation(getClass().getClassLoader().getResource("attributeMap.properties").getPath());
    spyAttributeQueryClaimsHandler.setSignatureProperties(signatureProperties);
    spyAttributeQueryClaimsHandler.setEncryptionProperties(encryptionProperties);
    doReturn(service).when(spyAttributeQueryClaimsHandler).createService();
    doReturn(dispatch).when(spyAttributeQueryClaimsHandler).createDispatcher(service);
    cannedResponse = Resources.toString(Resources.getResource(getClass(), "/SAMLResponse.xml"), Charsets.UTF_8);
}
Also used : SimpleSign(ddf.security.samlp.SimpleSign) SystemCrypto(ddf.security.samlp.SystemCrypto) EncryptionService(ddf.security.encryption.EncryptionService) StreamSource(javax.xml.transform.stream.StreamSource) Service(javax.xml.ws.Service) EncryptionService(ddf.security.encryption.EncryptionService) XMLObject(org.opensaml.core.xml.XMLObject) Before(org.junit.Before)

Example 64 with Service

use of javax.xml.ws.Service in project ddf by codice.

the class AttributeQueryClaimsHandler method createService.

/**
     * Creates a dynamic service from the provided wsdl location.
     */
protected Service createService() {
    Service service = null;
    URL wsdlURL;
    if (StringUtils.isNotBlank(wsdlLocation) && StringUtils.isNotBlank(serviceName)) {
        try {
            URIResolver uriResolver = new URIResolver();
            uriResolver.resolve("", wsdlLocation, this.getClass());
            wsdlURL = uriResolver.isResolved() ? uriResolver.getURL() : new URL(wsdlLocation);
            service = Service.create(wsdlURL, QName.valueOf(serviceName));
            auditRemoteConnection(wsdlURL);
        } catch (Exception e) {
            LOGGER.info("Unable to create service from WSDL location. Set log level for \"org.codice.ddf.security.claims.attributequery.common\" to DEBUG for more information.");
            LOGGER.debug("Unable to create service from WSDL location.", e);
        }
    }
    return service;
}
Also used : Service(javax.xml.ws.Service) URIResolver(org.apache.cxf.resource.URIResolver) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException)

Example 65 with Service

use of javax.xml.ws.Service in project cxf by apache.

the class BinarySecurityTokenTest method testBadBinarySecurityToken.

@org.junit.Test
public void testBadBinarySecurityToken() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = BinarySecurityTokenTest.class.getResource("cxf-bad-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = BinarySecurityTokenTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricBSTPort");
    DoubleItPortType asymmetricBSTPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(asymmetricBSTPort, test.getPort());
    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(asymmetricBSTPort);
    }
    try {
        doubleIt(asymmetricBSTPort, 30);
        fail("Expected failure on a bad cert");
    } catch (javax.xml.ws.soap.SOAPFaultException fault) {
    // expected
    }
    ((java.io.Closeable) asymmetricBSTPort).close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) DoubleItPortType(org.example.contract.doubleit.DoubleItPortType) URL(java.net.URL)

Aggregations

Service (javax.xml.ws.Service)598 URL (java.net.URL)547 QName (javax.xml.namespace.QName)524 Bus (org.apache.cxf.Bus)399 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)384 DoubleItPortType (org.example.contract.doubleit.DoubleItPortType)361 Test (org.junit.Test)143 BindingProvider (javax.xml.ws.BindingProvider)63 Client (org.apache.cxf.endpoint.Client)43 HashMap (java.util.HashMap)36 SamlCallbackHandler (org.apache.cxf.systest.ws.saml.client.SamlCallbackHandler)31 STSClient (org.apache.cxf.ws.security.trust.STSClient)28 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)25 WebServiceException (javax.xml.ws.WebServiceException)20 WebService (javax.jws.WebService)18 IOException (java.io.IOException)16 File (java.io.File)15 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)15 Greeter (org.apache.hello_world_soap_http.Greeter)15 KeystorePasswordCallback (org.apache.cxf.systest.ws.common.KeystorePasswordCallback)14