List of usage examples for javax.xml.ws Service create
public static Service create(QName serviceName, WebServiceFeature... features)
From source file:at.gv.egovernment.moa.id.protocols.stork2.attributeproviders.SignedDocAttributeRequestProvider.java
/** * Get mime type of document from DTL//from w ww . j a v a2s . co m * @param docId The document id * @param dtlUrl The url of dtl * @return The mime type */ private String getDocumentMimeFromDtl(String docId, String eDtlUrl) throws Exception { URL url = null; try { url = new URL(dtlUrl); QName qname = new QName("http://stork.eu", "DocumentService"); Service service = Service.create(url, qname); DocumentService docservice = service.getPort(DocumentService.class); BindingProvider bp = (BindingProvider) docservice; SOAPBinding binding = (SOAPBinding) bp.getBinding(); binding.setMTOMEnabled(true); if (eDtlUrl.equalsIgnoreCase(dtlUrl)) return docservice.getDocumentMime(docId, ""); else return docservice.getDocumentMime(docId, eDtlUrl); } catch (Exception e) { e.printStackTrace(); throw new Exception("Error in getDocumentFromDtl", e); } }
From source file:at.gv.egovernment.moa.id.protocols.stork2.attributeproviders.SignedDocAttributeRequestProvider.java
/** * Update document in DTL//from w w w.jav a 2 s . c o m * @param docData The docment data * @param docId The document ID * @param signResponse The signature response * @return True if successful * @throws SimpleException */ private boolean updateDocumentInDtl(byte[] docData, String docId, String signResponse) throws Exception { boolean success = false; URL url = null; try { url = new URL(dtlUrl); QName qname = new QName("http://stork.eu", "DocumentService"); Service service = Service.create(url, qname); DocumentService docservice = service.getPort(DocumentService.class); BindingProvider bp = (BindingProvider) docservice; SOAPBinding binding = (SOAPBinding) bp.getBinding(); binding.setMTOMEnabled(true); success = docservice.updateDocument(docId, signResponse, docData); } catch (Exception e) { e.printStackTrace(); throw new Exception("Error in updateDocumentInDtl", e); } return success; }
From source file:at.gv.egovernment.moa.id.auth.servlet.PEPSConnectorServlet.java
/** * Get document from DTL//from w w w . j a v a 2s. c o m * @param transferRequest The transfer request (attribute query) * @param eDtlUrl The DTL url of external DTL * @return the document data * @throws SimpleException */ private byte[] getDocumentFromDtl(String transferRequest, String eDtlUrl) throws Exception { URL url = null; try { Logger.debug("getDocumentFromDtl, dtlUrl:'" + dtlUrl + "' eDtlUrl:'" + eDtlUrl + "'"); url = new URL(dtlUrl); QName qname = new QName("http://stork.eu", "DocumentService"); Service service = Service.create(url, qname); DocumentService docservice = service.getPort(DocumentService.class); BindingProvider bp = (BindingProvider) docservice; SOAPBinding binding = (SOAPBinding) bp.getBinding(); binding.setMTOMEnabled(true); if (eDtlUrl.equalsIgnoreCase(dtlUrl)) return docservice.getDocument(transferRequest, ""); else return docservice.getDocument(transferRequest, eDtlUrl); } catch (Exception e) { e.printStackTrace(); throw new Exception("Error in getDocumentFromDtl", e); } }
From source file:nl.tue.gale.geb.GEBManager.java
private void init() { if (!"true".equals(GaleUtil.getProperty("useGEB"))) return;/*from ww w.jav a 2 s. c o m*/ if (initialized) return; try { URL url; Service service; url = new URL(gebURL, "gebListenerService?wsdl"); service = Service.create(url, new QName("http://j2ee.netbeans.org/wsdl/GEB/gebListener", "gebListenerService")); gebListenerService = (GEBListenerService) service.getPort( new QName("http://j2ee.netbeans.org/wsdl/GEB/gebListener", "gebListenerPort"), GEBListenerService.class); url = new URL(gebURL, "eventGEBListenerService?wsdl"); service = Service.create(url, new QName("http://j2ee.netbeans.org/wsdl/GEB/eventGEBListener", "eventGEBListenerService")); eventGEBListenerService = (EventGEBListenerService) service.getPort( new QName("http://j2ee.netbeans.org/wsdl/GEB/eventGEBListener", "eventGEBListenerPort"), EventGEBListenerService.class); } catch (Exception e) { throw new IllegalArgumentException("unable to initialize GEBManager: " + e.getMessage(), e); } initialized = true; try { for (Map.Entry<String, String> entry : autoRegister.entrySet()) { if (!registerService(entry.getValue().trim(), Arrays.asList(entry.getKey().trim().split(";")))) System.out.println("unable to register (assuming already registered)"); } } catch (Exception e) { throw new IllegalArgumentException( "unable to auto-register the EventListener on GEB: " + e.getMessage(), e); } }
From source file:org.apache.coheigea.cxf.jdbc.authentication.AuthenticationTest.java
@org.junit.Test public void testAuthenticatedRequestViaJetty() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = AuthenticationTest.class.getResource("cxf-client.xml"); Bus bus = bf.createBus(busFile.toString()); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl = AuthenticationTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItTransportUTJettyPort"); DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class); TestUtil.updateAddressPort(transportPort, PORT); Client client = ClientProxy.getClient(transportPort); client.getRequestContext().put("ws-security.username", "alice"); doubleIt(transportPort, 25);/* w ww. j ava 2 s . c om*/ }
From source file:org.apache.coheigea.cxf.jdbc.authentication.AuthenticationTest.java
@org.junit.Test public void testUnauthenticatedRequestViaJetty() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = AuthenticationTest.class.getResource("cxf-client.xml"); Bus bus = bf.createBus(busFile.toString()); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl = AuthenticationTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItTransportUTJettyPort"); DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class); TestUtil.updateAddressPort(transportPort, PORT); Client client = ClientProxy.getClient(transportPort); client.getRequestContext().put("ws-security.username", "bob"); try {/*from www . j av a2 s . c o m*/ doubleIt(transportPort, 25); Assert.fail("Failure expected on bob"); } catch (Exception ex) { // expected } }
From source file:org.apache.coheigea.cxf.jdbc.authorization.AuthorizationTest.java
@org.junit.Test public void testAuthorizedRequestViaJetty() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = AuthorizationTest.class.getResource("cxf-client.xml"); Bus bus = bf.createBus(busFile.toString()); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl = AuthorizationTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItTransportUTJettyPort"); DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class); TestUtil.updateAddressPort(transportPort, PORT); Client client = ClientProxy.getClient(transportPort); client.getRequestContext().put("ws-security.username", "alice"); doubleIt(transportPort, 25);/* www .ja va 2 s . c o m*/ }
From source file:org.apache.coheigea.cxf.jdbc.authorization.AuthorizationTest.java
@org.junit.Test public void testUnauthorizedRequestViaJetty() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = AuthorizationTest.class.getResource("cxf-client.xml"); Bus bus = bf.createBus(busFile.toString()); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl = AuthorizationTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItTransportUTJettyPort"); DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class); TestUtil.updateAddressPort(transportPort, PORT); Client client = ClientProxy.getClient(transportPort); client.getRequestContext().put("ws-security.username", "bob"); try {/*from w ww.jav a 2 s .c o m*/ doubleIt(transportPort, 25); Assert.fail("Failure expected on bob"); } catch (Exception ex) { // expected } }
From source file:org.apache.coheigea.cxf.kerberos.authentication.AuthenticationTest.java
@org.junit.Test public void testKerberos() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = AuthenticationTest.class.getResource("cxf-client.xml"); Bus bus = bf.createBus(busFile.toString()); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl = AuthenticationTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItKerberosTransportPort"); DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class); TestUtil.updateAddressPort(transportPort, PORT); doubleIt(transportPort, 25);/*from w w w . j av a 2 s .c o m*/ }
From source file:org.apache.coheigea.cxf.kerberos.authentication.AuthenticationTest.java
@org.junit.Test public void testSpnego() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = AuthenticationTest.class.getResource("cxf-client.xml"); Bus bus = bf.createBus(busFile.toString()); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl = AuthenticationTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItSpnegoTransportPort"); DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class); TestUtil.updateAddressPort(transportPort, PORT); doubleIt(transportPort, 25);/*from w ww . j av a2 s. co m*/ }