use of com.sun.xml.ws.developer.MemberSubmissionEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testCreateDispatchSMWsdlMSEPRNoPortQName.
public void testCreateDispatchSMWsdlMSEPRNoPortQName() throws Exception {
if (ClientServerTestUtil.useLocal()) {
System.out.println("HTTP Transport Only Exiting");
return;
}
RespectBindingFeature rbf = new RespectBindingFeature(false);
WebServiceFeature[] wse = new WebServiceFeature[] { rbf };
Service service = createServiceWithWSDL();
MemberSubmissionEndpointReference msEPR = createMSEPRStubServiceWithWSDL(service);
msEPR.portTypeName.name = null;
MSEPRString = msEPR.toString();
Dispatch<SOAPMessage> dispatch = service.createDispatch(EndpointReference.readFrom(makeStreamSource(MSEPRString)), SOAPMessage.class, Service.Mode.MESSAGE, wse);
SOAPMessage sm = dispatch.invoke(getSOAPMessage(makeStreamSource(SMMsg)));
sm.writeTo(System.out);
// System.out.println("Adding numbers 2 and 4");
// int result = dispatch.invoke(getSOAPMessage())
// assert(result == 6);
// System.out.println("Addinion of 2 and 4 successful");
}
use of com.sun.xml.ws.developer.MemberSubmissionEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class EndpointReferenceUtil method toMSEpr.
// private static void writeW3CMetadata(StreamWriterBufferCreator writer) throws XMLStreamException {
// if (!w3cMetadataWritten) {
// writer.writeStartElement(AddressingVersion.W3C.getPrefix(), AddressingVersion.W3C.eprType.wsdlMetadata.getLocalPart(), AddressingVersion.W3C.nsUri);
// w3cMetadataWritten = true;
// }
// }
//
private static MemberSubmissionEndpointReference toMSEpr(W3CEndpointReference w3cEpr) {
DOMResult result = new DOMResult();
w3cEpr.writeTo(result);
Node eprNode = result.getNode();
Element e = DOMUtil.getFirstElementChild(eprNode);
if (e == null) {
return null;
}
MemberSubmissionEndpointReference msEpr = new MemberSubmissionEndpointReference();
NodeList nodes = e.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
if (nodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
Element child = (Element) nodes.item(i);
if (child.getNamespaceURI().equals(AddressingVersion.W3C.nsUri) && child.getLocalName().equals(AddressingVersion.W3C.eprType.address)) {
if (msEpr.addr == null) {
msEpr.addr = new MemberSubmissionEndpointReference.Address();
}
msEpr.addr.uri = XmlUtil.getTextForNode(child);
} else if (child.getNamespaceURI().equals(AddressingVersion.W3C.nsUri) && child.getLocalName().equals("ReferenceParameters")) {
NodeList refParams = child.getChildNodes();
for (int j = 0; j < refParams.getLength(); j++) {
if (refParams.item(j).getNodeType() == Node.ELEMENT_NODE) {
if (msEpr.referenceParameters == null) {
msEpr.referenceParameters = new MemberSubmissionEndpointReference.Elements();
msEpr.referenceParameters.elements = new ArrayList<>();
}
msEpr.referenceParameters.elements.add((Element) refParams.item(j));
}
}
} else if (child.getNamespaceURI().equals(AddressingVersion.W3C.nsUri) && child.getLocalName().equals(AddressingVersion.W3C.eprType.wsdlMetadata.getLocalPart())) {
NodeList metadata = child.getChildNodes();
String wsdlLocation = child.getAttributeNS(W3CAddressingMetadataConstants.WSAM_WSDLI_ATTRIBUTE_NAMESPACE, W3CAddressingMetadataConstants.WSAM_WSDLI_ATTRIBUTE_LOCALNAME);
Element wsdlDefinitions = null;
for (int j = 0; j < metadata.getLength(); j++) {
Node node = metadata.item(j);
if (node.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
Element elm = (Element) node;
if ((elm.getNamespaceURI().equals(AddressingVersion.W3C.wsdlNsUri) || elm.getNamespaceURI().equals(W3CAddressingMetadataConstants.WSAM_NAMESPACE_NAME)) && elm.getLocalName().equals(AddressingVersion.W3C.eprType.serviceName)) {
msEpr.serviceName = new MemberSubmissionEndpointReference.ServiceNameType();
msEpr.serviceName.portName = elm.getAttribute(AddressingVersion.W3C.eprType.portName);
String service = elm.getTextContent();
String prefix = XmlUtil.getPrefix(service);
String name = XmlUtil.getLocalPart(service);
// if there is no service name then its not a valid EPR but lets continue as its optional anyway
if (name == null) {
continue;
}
if (prefix != null) {
String ns = elm.lookupNamespaceURI(prefix);
if (ns != null) {
msEpr.serviceName.name = new QName(ns, name, prefix);
}
} else {
msEpr.serviceName.name = new QName(null, name);
}
msEpr.serviceName.attributes = getAttributes(elm);
} else if ((elm.getNamespaceURI().equals(AddressingVersion.W3C.wsdlNsUri) || elm.getNamespaceURI().equals(W3CAddressingMetadataConstants.WSAM_NAMESPACE_NAME)) && elm.getLocalName().equals(AddressingVersion.W3C.eprType.portTypeName)) {
msEpr.portTypeName = new MemberSubmissionEndpointReference.AttributedQName();
String portType = elm.getTextContent();
String prefix = XmlUtil.getPrefix(portType);
String name = XmlUtil.getLocalPart(portType);
// if there is no portType name then its not a valid EPR but lets continue as its optional anyway
if (name == null) {
continue;
}
if (prefix != null) {
String ns = elm.lookupNamespaceURI(prefix);
if (ns != null) {
msEpr.portTypeName.name = new QName(ns, name, prefix);
}
} else {
msEpr.portTypeName.name = new QName(null, name);
}
msEpr.portTypeName.attributes = getAttributes(elm);
} else if (elm.getNamespaceURI().equals(WSDLConstants.NS_WSDL) && elm.getLocalName().equals(WSDLConstants.QNAME_DEFINITIONS.getLocalPart())) {
wsdlDefinitions = elm;
} else {
// its extensions in META-DATA and should be copied to extensions in MS EPR
if (msEpr.elements == null) {
msEpr.elements = new ArrayList<>();
}
msEpr.elements.add(elm);
}
}
Document doc = DOMUtil.createDom();
Element mexEl = doc.createElementNS(MemberSubmissionAddressingConstants.MEX_METADATA.getNamespaceURI(), MemberSubmissionAddressingConstants.MEX_METADATA.getPrefix() + ":" + MemberSubmissionAddressingConstants.MEX_METADATA.getLocalPart());
Element metadataEl = doc.createElementNS(MemberSubmissionAddressingConstants.MEX_METADATA_SECTION.getNamespaceURI(), MemberSubmissionAddressingConstants.MEX_METADATA_SECTION.getPrefix() + ":" + MemberSubmissionAddressingConstants.MEX_METADATA_SECTION.getLocalPart());
metadataEl.setAttribute(MemberSubmissionAddressingConstants.MEX_METADATA_DIALECT_ATTRIBUTE, MemberSubmissionAddressingConstants.MEX_METADATA_DIALECT_VALUE);
if (wsdlDefinitions == null && wsdlLocation != null && !wsdlLocation.equals("")) {
wsdlLocation = wsdlLocation.trim();
String wsdlTns = wsdlLocation.substring(0, wsdlLocation.indexOf(' '));
wsdlLocation = wsdlLocation.substring(wsdlLocation.indexOf(' ') + 1);
Element wsdlEl = doc.createElementNS(WSDLConstants.NS_WSDL, WSDLConstants.PREFIX_NS_WSDL + ":" + WSDLConstants.QNAME_DEFINITIONS.getLocalPart());
Element wsdlImportEl = doc.createElementNS(WSDLConstants.NS_WSDL, WSDLConstants.PREFIX_NS_WSDL + ":" + WSDLConstants.QNAME_IMPORT.getLocalPart());
wsdlImportEl.setAttribute("namespace", wsdlTns);
wsdlImportEl.setAttribute("location", wsdlLocation);
wsdlEl.appendChild(wsdlImportEl);
metadataEl.appendChild(wsdlEl);
} else if (wsdlDefinitions != null) {
metadataEl.appendChild(wsdlDefinitions);
}
mexEl.appendChild(metadataEl);
if (msEpr.elements == null) {
msEpr.elements = new ArrayList<>();
}
msEpr.elements.add(mexEl);
} else {
// its extensions
if (msEpr.elements == null) {
msEpr.elements = new ArrayList<>();
}
msEpr.elements.add(child);
}
} else if (nodes.item(i).getNodeType() == Node.ATTRIBUTE_NODE) {
Node n = nodes.item(i);
if (msEpr.attributes == null) {
msEpr.attributes = new HashMap<>();
String prefix = fixNull(n.getPrefix());
String ns = fixNull(n.getNamespaceURI());
String localName = n.getLocalName();
msEpr.attributes.put(new QName(ns, localName, prefix), n.getNodeValue());
}
}
}
return msEpr;
}
use of com.sun.xml.ws.developer.MemberSubmissionEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class EndpointEPRTester method testProviderEndpointMSCEPR_WSDL.
public void testProviderEndpointMSCEPR_WSDL() throws Exception {
int port = Util.getFreePort();
String address = "http://127.0.0.1:" + port + "/";
Endpoint e = Endpoint.create(HTTPBinding.HTTP_BINDING, new MyProvider());
List<Source> metadata = new ArrayList<Source>();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
String[] docs = { "WEB-INF/wsdl/RpcLitEndpoint.wsdl", "WEB-INF/wsdl/RpcLitAbstract.wsdl", "WEB-INF/wsdl/RpcLitEndpoint.xsd" };
for (String doc : docs) {
URL url = cl.getResource(doc);
metadata.add(new StreamSource(url.openStream(), url.toExternalForm()));
}
e.setMetadata(metadata);
Map<String, Object> endpointProps = new HashMap<String, Object>();
endpointProps.put(Endpoint.WSDL_SERVICE, new QName("http://echo.org/", "RpcLitEndpoint"));
endpointProps.put(Endpoint.WSDL_PORT, new QName("http://echo.org/", "RpcLitPort"));
e.setProperties(endpointProps);
e.publish(address);
MemberSubmissionEndpointReference epr = e.getEndpointReference(MemberSubmissionEndpointReference.class);
e.stop();
EprUtil.validateEPR(epr, address, serviceName, portName, portTypeName, Boolean.TRUE);
printEPR(epr);
}
use of com.sun.xml.ws.developer.MemberSubmissionEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class EndpointEPRTester method testProviderEndpointMSCEPR.
public void testProviderEndpointMSCEPR() {
int port = Util.getFreePort();
String address = "http://127.0.0.1:" + port + "/";
Endpoint e = Endpoint.create(HTTPBinding.HTTP_BINDING, new MyProvider());
e.publish(address);
MemberSubmissionEndpointReference epr = e.getEndpointReference(MemberSubmissionEndpointReference.class);
e.stop();
EprUtil.validateEPR(epr, address, null, null, null, Boolean.FALSE);
printEPR(epr);
}
use of com.sun.xml.ws.developer.MemberSubmissionEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class ClientEpr method msEprGettertest.
private void msEprGettertest(BindingProvider bp, boolean hasWSDL) throws Exception {
Service service = Service.create(serviceName);
service.addPort(portName, jakarta.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
Dispatch dispatch = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
// validate ms epr
MemberSubmissionEndpointReference msEpr = bp.getEndpointReference(MemberSubmissionEndpointReference.class);
// printEPR(msEpr);
assertTrue(EprUtil.validateEPR(msEpr, endpointAddress, serviceName, portName, portTypeName, hasWSDL));
W3CEndpointReference w3cEpr = bp.getEndpointReference(W3CEndpointReference.class);
// printEPR(w3cEpr);
// assertTrue(EprUtil.validateEPR(w3cEpr,endpointAddress, serviceName, portName, portTypeName, hasWSDL));
assertTrue(EprUtil.validateEPR(w3cEpr, endpointAddress, null, null, null, false));
}
Aggregations