请有人帮我找一些使用wsdl4j API解析wsdl url的示例。
由于
答案 0 :(得分:2)
试试这个;
public Definition readWSDLFile() throws WSDLException {
WSDLReader reader = getWsdlFactoryInstance().newWSDLReader();
// switch off the verbose mode
reader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false);
reader.setFeature("javax.wsdl.importDocuments", true);
Definition wsdlDefinition;
if (log.isDebugEnabled()) {
log.debug("Reading the WSDL. Base uri is " + baseURI);
}
wsdlDefinition = reader.readWSDL(baseURI);
return wsdlDefinition;
}
使用定义,您可以访问操作,服务对象..以访问服务地址位置;
private void setServiceDefinition(Definition definition) throws Exception {
Map serviceMap = definition.getAllServices();
Iterator serviceItr = serviceMap.entrySet().iterator();
URL addressURI = null;
try {
while (serviceItr.hasNext()) {
Map.Entry svcEntry = (Map.Entry) serviceItr.next();
Service svc = (Service) svcEntry.getValue();
Map portMap = svc.getPorts();
Iterator portItr = portMap.entrySet().iterator();
while (portItr.hasNext()) {
Map.Entry portEntry = (Map.Entry) portItr.next();
Port port = (Port) portEntry.getValue();
ExtensibilityElement extensibilityElement = (ExtensibilityElement) port.getExtensibilityElements()
.get(0);
addressURI = new URL(getAddressUrl(extensibilityElement));
}
}
这是我写的sample,可能对你有用。