javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder Java Examples
The following examples show how to use
javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocatorServiceImpl.java From cxf with Apache License 2.0 | 6 votes |
public javax.xml.ws.wsaddressing.W3CEndpointReference lookupEndpoint( javax.xml.namespace.QName serviceQname) throws EndpointNotExistFault { LOG.info("Executing operation lookupEndpoint"); W3CEndpointReferenceBuilder eprBuilder = new W3CEndpointReferenceBuilder(); eprBuilder.address("http://bar"); eprBuilder.serviceName(serviceQname); eprBuilder.wsdlDocumentLocation("wsdlLoc"); // just in case, for backward compatibility, the builder may be asked to // create a wsdlLocation attribute with a location only if (serviceQname.getNamespaceURI().endsWith("2")) { Message m = PhaseInterceptorChain.getCurrentMessage(); m.put("org.apache.cxf.wsa.metadata.wsdlLocationOnly", "true"); } ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); return eprBuilder.build(); } finally { Thread.currentThread().setContextClassLoader(cl); } }
Example #2
Source File: DispatchClientServerTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testJAXBObjectPAYLOADFromEPR() throws Exception { URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service = new SOAPService(wsdl, SERVICE_NAME); assertNotNull(service); W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); builder.address("http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort"); builder.serviceName(SERVICE_NAME); builder.endpointName(PORT_NAME); W3CEndpointReference w3cEpr = builder.build(); JAXBContext jc = JAXBContext.newInstance("org.apache.hello_world_soap_http.types"); Dispatch<Object> disp = service.createDispatch(w3cEpr, jc, Service.Mode.PAYLOAD, new AddressingFeature()); doJAXBPayload(disp); }
Example #3
Source File: EjbMessageContext.java From tomee with Apache License 2.0 | 6 votes |
public EndpointReference getEndpointReference(Element... referenceParameters) { org.apache.cxf.message.Message msg = getWrappedMessage(); Endpoint ep = msg.getExchange().get(Endpoint.class); W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); builder.address(ep.getEndpointInfo().getAddress()); builder.serviceName(ep.getService().getName()); builder.endpointName(ep.getEndpointInfo().getName()); if (referenceParameters != null) { for (Element referenceParameter : referenceParameters) { builder.referenceParameter(referenceParameter); } } return builder.build(); }
Example #4
Source File: LocatorClientServerTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testIllegalState() throws Exception { W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); try { builder.build(); fail("Address in an EPR cannot be null, when serviceName or portName is null"); } catch (IllegalStateException ie) { // expected } catch (Exception e) { fail("Unexpected Exception " + e.getClass() + " raised: " + e.getMessage()); } }
Example #5
Source File: DispatchClientServerTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testCreateDispatchWithEPR() throws Exception { URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service = new SOAPService(wsdl, SERVICE_NAME); assertNotNull(service); W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); builder.address("http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort"); builder.serviceName(SERVICE_NAME); builder.endpointName(PORT_NAME); W3CEndpointReference w3cEpr = builder.build(); Dispatch<SOAPMessage> disp = service .createDispatch(w3cEpr, SOAPMessage.class, Service.Mode.MESSAGE); InputStream is = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml"); SOAPMessage soapReqMsg = MessageFactory.newInstance().createMessage(null, is); assertNotNull(soapReqMsg); SOAPMessage soapResMsg = disp.invoke(soapReqMsg); assertNotNull(soapResMsg); String expected = "Hello TestSOAPInputMessage"; assertEquals("Response should be : Hello TestSOAPInputMessage", expected, DOMUtils.getAllContent(SAAJUtils.getBody(soapResMsg)).trim()); }
Example #6
Source File: WSNHelper.java From cxf with Apache License 2.0 | 5 votes |
public W3CEndpointReference createWSA(String address) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { if (setClassLoader) { Thread.currentThread().setContextClassLoader(WSNHelper.class.getClassLoader()); } return new W3CEndpointReferenceBuilder().address(address).build(); } finally { Thread.currentThread().setContextClassLoader(cl); } }
Example #7
Source File: EndpointImpl.java From cxf with Apache License 2.0 | 5 votes |
public EndpointReference getEndpointReference(Element... referenceParameters) { if (!isPublished()) { throw new WebServiceException(new org.apache.cxf.common.i18n.Message("ENDPOINT_NOT_PUBLISHED", LOG).toString()); } if (getBinding() instanceof HTTPBinding) { throw new UnsupportedOperationException(new org.apache.cxf.common.i18n.Message( "GET_ENDPOINTREFERENCE_UNSUPPORTED_BINDING", LOG).toString()); } W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); builder.address(address); builder.serviceName(serviceName); builder.endpointName(endpointName); if (referenceParameters != null) { for (Element referenceParameter : referenceParameters) { builder.referenceParameter(referenceParameter); } } builder.wsdlDocumentLocation(wsdlLocation); ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(EndpointReferenceBuilder.class.getClassLoader()); return builder.build(); } finally { Thread.currentThread().setContextClassLoader(cl); } }
Example #8
Source File: WSDiscoveryClient.java From cxf with Apache License 2.0 | 4 votes |
private W3CEndpointReference generateW3CEndpointReference() { W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); builder.address(ContextUtils.generateUUID()); return builder.build(); }
Example #9
Source File: WSDiscoveryServiceImpl.java From cxf with Apache License 2.0 | 4 votes |
public void serverStarted(Server server) { Object o = getProperty(server, "ws-discovery-disable"); if (o == Boolean.TRUE || Boolean.valueOf((String)o)) { return; } if (!startup(true)) { return; } HelloType ht = new HelloType(); ht.setScopes(new ScopesType()); ht.setMetadataVersion(1); o = getProperty(server, "ws-discovery-types"); if (o instanceof QName) { ht.getTypes().add((QName)o); } else if (o instanceof List) { for (Object o2 : (List<?>)o) { if (o2 instanceof QName) { ht.getTypes().add((QName)o2); } else if (o2 instanceof String) { ht.getTypes().add(QName.valueOf((String)o2)); } } } else if (o instanceof String) { ht.getTypes().add(QName.valueOf((String)o)); } if (ht.getTypes().isEmpty()) { QName sn = ServiceModelUtil.getServiceQName(server.getEndpoint().getEndpointInfo()); ht.getTypes().add(sn); } o = getProperty(server, "ws-discovery-scopes"); if (o != null) { setScopes(ht, o); } setXAddrs(ht, server); String uuid = (String)getProperty(server, "ws-discovery-uuid"); if (uuid != null) { //persistent uuid W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); builder.address(uuid); ht.setEndpointReference(builder.build()); } ht = client.register(ht); registered.add(ht); server.getEndpoint().put(HelloType.class.getName(), ht); }
Example #10
Source File: EndpointReferenceBuilder.java From cxf with Apache License 2.0 | 4 votes |
public EndpointReference getEndpointReference() { //if there is epr in wsdl, direct return this EPR List<ExtensibilityElement> portExtensors = endpoint.getEndpointInfo() .getExtensors(ExtensibilityElement.class); if (portExtensors != null) { Iterator<ExtensibilityElement> extensionElements = portExtensors.iterator(); QName wsaEpr = new QName(Names.WSA_NAMESPACE_NAME, "EndpointReference"); while (extensionElements.hasNext()) { ExtensibilityElement ext = extensionElements.next(); if (ext instanceof UnknownExtensibilityElement && wsaEpr.equals(ext.getElementType())) { Element eprEle = ((UnknownExtensibilityElement)ext).getElement(); List<Element> addressElements = DOMUtils.getChildrenWithName(eprEle, Names.WSA_NAMESPACE_NAME, Names.WSA_ADDRESS_NAME); if (!addressElements.isEmpty()) { /* * [WSA-WSDL Binding] : in a SOAP 1.1 port described using WSDL 1.1, the location * attribute of a soap11:address element (if present) would have the same value as the * wsa:Address child element of the wsa:EndpointReference element. */ addressElements.get(0).setTextContent(this.endpoint.getEndpointInfo().getAddress()); } return EndpointReference.readFrom(new DOMSource(eprEle)); } } } String bindingId = endpoint.getJaxwsBinding().getBindingID(); if (!SOAPBindingImpl.isSoapBinding(bindingId)) { throw new UnsupportedOperationException(new Message("GET_ENDPOINTREFERENCE_UNSUPPORTED_BINDING", LOG, bindingId).toString()); } W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); builder.address(this.endpoint.getEndpointInfo().getAddress()); builder.serviceName(this.endpoint.getService().getName()); builder.endpointName(this.endpoint.getEndpointInfo().getName()); if (this.endpoint.getEndpointInfo().getService().getDescription() != null) { builder.wsdlDocumentLocation(this.endpoint.getEndpointInfo().getService().getDescription() .getBaseURI()); } ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(EndpointReferenceBuilder.class.getClassLoader()); return builder.build(); } finally { Thread.currentThread().setContextClassLoader(cl); } }