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);
}
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;
}
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);
}
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;
}
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);
}
Aggregations