use of com.sun.xml.ws.api.model.wsdl.WSDLModel in project metro-jax-ws by eclipse-ee4j.
the class WSServiceDelegate method getWSDLModelfromSEI.
private WSDLService getWSDLModelfromSEI(final Class sei) {
WebService ws = AccessController.doPrivileged(new PrivilegedAction<>() {
public WebService run() {
return (WebService) sei.getAnnotation(WebService.class);
}
});
if (ws == null || ws.wsdlLocation().equals(""))
return null;
String wsdlLocation = ws.wsdlLocation();
wsdlLocation = JAXWSUtils.absolutize(JAXWSUtils.getFileOrURLName(wsdlLocation));
Source wsdl = new StreamSource(wsdlLocation);
WSDLService service = null;
try {
URL url = wsdl.getSystemId() == null ? null : new URL(wsdl.getSystemId());
WSDLModel model = parseWSDL(url, wsdl, sei);
service = model.getService(this.serviceName);
if (service == null)
throw new WebServiceException(ClientMessages.INVALID_SERVICE_NAME(this.serviceName, buildNameList(model.getServices().keySet())));
} catch (MalformedURLException e) {
throw new WebServiceException(ClientMessages.INVALID_WSDL_URL(wsdl.getSystemId()));
}
return service;
}
use of com.sun.xml.ws.api.model.wsdl.WSDLModel in project metro-jax-ws by eclipse-ee4j.
the class EndpointFactory method getWSDLPort.
/**
* Parses the primary WSDL and returns the {@link WSDLPort} for the given service and port names
*
* @param primaryWsdl Primary WSDL
* @param metadata it may contain imported WSDL and schema documents
* @param serviceName service name in wsdl
* @param portName port name in WSDL
* @param container container in which this service is running
* @return non-null wsdl port object
*/
@NotNull
private static WSDLPort getWSDLPort(SDDocumentSource primaryWsdl, Collection<? extends SDDocumentSource> metadata, @NotNull QName serviceName, @NotNull QName portName, Container container, EntityResolver resolver) {
URL wsdlUrl = primaryWsdl.getSystemId();
try {
// TODO: delegate to another entity resolver
WSDLModel wsdlDoc = RuntimeWSDLParser.parse(new Parser(primaryWsdl), new EntityResolverImpl(metadata, resolver), false, container, ServiceFinder.find(WSDLParserExtension.class).toArray());
if (wsdlDoc.getServices().size() == 0) {
throw new ServerRtException(ServerMessages.localizableRUNTIME_PARSER_WSDL_NOSERVICE_IN_WSDLMODEL(wsdlUrl));
}
WSDLService wsdlService = wsdlDoc.getService(serviceName);
if (wsdlService == null) {
throw new ServerRtException(ServerMessages.localizableRUNTIME_PARSER_WSDL_INCORRECTSERVICE(serviceName, wsdlUrl));
}
WSDLPort wsdlPort = wsdlService.get(portName);
if (wsdlPort == null) {
throw new ServerRtException(ServerMessages.localizableRUNTIME_PARSER_WSDL_INCORRECTSERVICEPORT(serviceName, portName, wsdlUrl));
}
return wsdlPort;
} catch (IOException | ServiceConfigurationError | SAXException e) {
throw new ServerRtException("runtime.parser.wsdl", wsdlUrl, e);
} catch (XMLStreamException e) {
throw new ServerRtException("runtime.saxparser.exception", e.getMessage(), e.getLocation(), e);
}
}
use of com.sun.xml.ws.api.model.wsdl.WSDLModel in project metro-jax-ws by eclipse-ee4j.
the class SwaMimeAttachmentTest method getWSDLPort.
static WSDLPort getWSDLPort(URL wsdlLoc) throws Exception {
EntityResolver er = XmlUtil.createDefaultCatalogResolver();
WSDLModel wsdl = RuntimeWSDLParser.parse(wsdlLoc, new StreamSource(wsdlLoc.toExternalForm()), er, true, null, ServiceFinder.find(WSDLParserExtension.class).toArray());
QName serviceName = wsdl.getFirstServiceName();
return wsdl.getService(serviceName).getFirstPort();
}
use of com.sun.xml.ws.api.model.wsdl.WSDLModel in project metro-jax-ws by eclipse-ee4j.
the class WsDatabindingTestBase method createProxy.
public static <T> T createProxy(Class<T> proxySEI, DatabindingConfig srvConfig, DatabindingConfig cliConfig, boolean debug) throws Exception {
Class<?> endpointClass = srvConfig.getEndpointClass();
// TODO default BindingID
if (srvConfig.getMappingInfo().getBindingID() == null)
srvConfig.getMappingInfo().setBindingID(BindingID.parse(endpointClass));
Databinding srvDb = (Databinding) factory.createRuntime(srvConfig);
InVmWSDLResolver result = new InVmWSDLResolver();
WSDLGenInfo wsdlGenInfo = new WSDLGenInfo();
wsdlGenInfo.setWsdlResolver(result);
// wsdlGenInfo.setContainer(container);
wsdlGenInfo.setExtensions(ServiceFinder.find(WSDLGeneratorExtension.class).toArray());
wsdlGenInfo.setInlineSchemas(true);
srvDb.generateWSDL(wsdlGenInfo);
if (debug)
result.print();
WSDLModel wsdl = RuntimeWSDLParser.parse(result.getWsdlSource(), result.getEntityResolver(), false, null, new WSDLParserExtension[0]);
QName serviceName = wsdl.getFirstServiceName();
WSDLPort wsdlPort = wsdl.getService(serviceName).getFirstPort();
if (cliConfig.getWsdlPort() == null)
cliConfig.setWsdlPort(wsdlPort);
cliConfig.getMappingInfo().setServiceName(serviceName);
Databinding cliDb = (Databinding) factory.createRuntime(cliConfig);
Class<?>[] intf = { proxySEI };
WsDatabindingTestFacade h = new WsDatabindingTestFacade(cliDb, srvDb, endpointClass);
h.wireLog = debug;
Object proxy = Proxy.newProxyInstance(proxySEI.getClassLoader(), intf, h);
return proxySEI.cast(proxy);
}
use of com.sun.xml.ws.api.model.wsdl.WSDLModel in project metro-jax-ws by eclipse-ee4j.
the class WSAM_EPRTester method runMandatoryEPRTests.
private void runMandatoryEPRTests() throws Exception {
URL res = getClass().getClassLoader().getResource("epr/wsamTest.wsdl");
// assuming that this is a file:// URL.
File folder = new File(new File(res.getFile()).getParentFile(), "mandatory");
System.out.println("\n\nMandatory Tests:\n");
for (File f : folder.listFiles()) {
if (!f.getName().endsWith(".xml"))
continue;
System.out.println("***************************");
System.out.println("TestFile: " + f.getParentFile().getName() + "/" + f.getName());
try {
InputStream is = new FileInputStream(f);
StreamSource s = new StreamSource(is);
EndpointReference epr = EndpointReference.readFrom(s);
WSEndpointReference wsepr = new WSEndpointReference(epr);
System.out.println("Address: " + wsepr.getAddress());
WSEndpointReference.Metadata metadata = wsepr.getMetaData();
System.out.println("Metadata Valid?: true");
if (metadata.getPortTypeName() != null)
System.out.println("InterfaceName: " + metadata.getPortTypeName());
if (metadata.getServiceName() != null)
System.out.println("ServiceName: " + metadata.getServiceName());
if (metadata.getPortName() != null)
System.out.println("Endpoint: " + metadata.getPortName().getLocalPart());
String wsdliLocation = metadata.getWsdliLocation();
if (metadata.getWsdliLocation() != null) {
System.out.println("wsdli:wsdlLocation: " + wsdliLocation);
String wsdlLocation = wsdliLocation.substring(wsdliLocation.lastIndexOf(" "));
WSDLModel wsdlModel = RuntimeWSDLParser.parse(new URL(wsdlLocation), new StreamSource(wsdlLocation), XmlUtil.createDefaultCatalogResolver(), false, Container.NONE, ServiceFinder.find(WSDLParserExtension.class).toArray());
QName binding = wsdlModel.getBinding(metadata.getServiceName(), metadata.getPortName()).getName();
System.out.println("Binding from WSDL: " + binding);
}
System.out.println("");
} catch (Exception e) {
System.out.println("Metadata Valid?: false");
System.out.println(e.getMessage());
// e.printStackTrace();
}
}
}
Aggregations