如何通过一个服务的Url得到它的wsdl的内容啊!从而可以读取服务名字和服务方法的名字? 比如有一地址:URLEndpoint myEndpoint = new URLEndpoint("http://127.0.0.1:8080/axis/HelloService.jws?wsdl"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个服务的wsdl为:<?xml version="1.0" encoding="UTF-8" ?> - <wsdl:definitions targetNamespace="http://127.0.0.1:8080/axis/HelloService.jws" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://127.0.0.1:8080/axis/HelloService.jws" xmlns:intf="http://127.0.0.1:8080/axis/HelloService.jws" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">- <!-- WSDL created by Apache Axis version: 1.3Built on Oct 05, 2005 (05:23:37 EDT) --> - <wsdl:message name="sayHelloResponse"> <wsdl:part name="sayHelloReturn" type="xsd:string" /> </wsdl:message>- <wsdl:message name="sayHelloRequest"> <wsdl:part name="username" type="xsd:string" /> </wsdl:message>- <wsdl:portType name="HelloService">- <wsdl:operation name="sayHello" parameterOrder="username"> <wsdl:input message="impl:sayHelloRequest" name="sayHelloRequest" /> <wsdl:output message="impl:sayHelloResponse" name="sayHelloResponse" /> </wsdl:operation> </wsdl:portType>- <wsdl:binding name="HelloServiceSoapBinding" type="impl:HelloService"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> - <wsdl:operation name="sayHello"> <wsdlsoap:operation soapAction="" /> - <wsdl:input name="sayHelloRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded" /> </wsdl:input>- <wsdl:output name="sayHelloResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://127.0.0.1:8080/axis/HelloService.jws" use="encoded" /> </wsdl:output> </wsdl:operation> </wsdl:binding>- <wsdl:service name="HelloServiceService">- <wsdl:port binding="impl:HelloServiceSoapBinding" name="HelloService"> <wsdlsoap:address location="http://127.0.0.1:8080/axis/HelloService.jws" /> </wsdl:port> </wsdl:service> </wsdl:definitions> 你先获取他的流,然后对流进行解析就可以了 HttpConnection http = null; try{ http = (HttpConnection)Connector.open(url, Connector.READ); }catch(IOException ioe){ System.out.println("ioe:"+ioe.toString()); } return http;InputStream is = null;is = httpconn.openInputStream(); 这里是获取流 需要先把流转为Document 对象,然后再对Document对象进行解析,需要用到xml解析包 public static Document getDocument(String url){ //声明一个Document Document doc = new Document(); //声明一个XmlParaser XmlParser xParser = null; //声明一个NewXmlParase NewXmlParase nXml = new NewXmlParase(); //获取输入流 InputStream is = nXml.getClass().getResourceAsStream(url); //利用输入流为参数,转化为读流 InputStreamReader isr = NewXmlParase.getStreamByString(NewXmlParase.getUTFString(is)); try{ //实例化xParser xParser = new XmlParser(isr); // doc.parse(xParser); //将xParser置为空 xParser = null; //捕获异常 }catch(Exception e){ xParser = null; doc = null; return null; } //返回doc return doc; }另一种方法:public static Document getDocument(InputStream is){ Document doc = new Document(); //声明一个XmlParaser XmlParser xParser = null; //利用输入流为参数,转化为读流 InputStreamReader isr = NewXmlParase.getStreamByString(NewXmlParase.getUTFString(is)); try{ xParser = new XmlParser(isr); doc.parse(xParser); xParser = null; }catch(Exception ioe){ doc = null; xParser = null; return null; } return doc; }用wsdl4j可以直接处理的 ,它是一个包http://wsdl4j.sourceforge.net/downloads/ 用wsdl4j来得到Wsdl的文档,用wsdlReader读了之后怎么把 Definition def 转成能够操作的形式呢,这之后好像没有办法取得它的元素和属性的值啊String wsdlURL = "http://127.0.0.1:8080/axis/HelloService.jws?wsdl";WSDLFactory wsdlFactory;try { wsdlFactory = WSDLFactoryImpl.newInstance(); WSDLReader wsdlReader = wsdlFactory.newWSDLReader(); wsdlReader.setFeature("javax.wsdl.verbose",false); wsdlReader.setFeature("javax.wsdl.importDocuments",true); Definition def = wsdlReader.readWSDL(wsdlURL); 而且我用下面的代码后,显示元素为空Element element = def.getDocumentationElement();//显示结果System.out.println("element: "+element);结果:element: null这是如何解决呢 SWT中使用Canvas显示图片,实现图片的拖动的问题。 关于传输文件? jfreechart画K线图,怎么排除不需要的时间 急--文件目录的选择 关于java程序里面大小写问题,想请教大家 简单,高分!!我怎么样能去得14天后的时间 討論jfreereport和JasperReports哪一個比較好,低手免進,up無分 刚开始学习JAVA,还不太清楚JAVA虚拟机是什么?所谓的虚拟机JVM究竟是因何得来的?哪位告知不胜感激! 关于JFrame 请给个思路! 看java多线程和定时器,有些疑惑,望朋友们指教,谢谢。 java的各种排序方法..
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="http://127.0.0.1:8080/axis/HelloService.jws" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://127.0.0.1:8080/axis/HelloService.jws" xmlns:intf="http://127.0.0.1:8080/axis/HelloService.jws" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <!--
WSDL created by Apache Axis version: 1.3
Built on Oct 05, 2005 (05:23:37 EDT) -->
- <wsdl:message name="sayHelloResponse">
<wsdl:part name="sayHelloReturn" type="xsd:string" />
</wsdl:message>
- <wsdl:message name="sayHelloRequest">
<wsdl:part name="username" type="xsd:string" />
</wsdl:message>
- <wsdl:portType name="HelloService">
- <wsdl:operation name="sayHello" parameterOrder="username">
<wsdl:input message="impl:sayHelloRequest" name="sayHelloRequest" />
<wsdl:output message="impl:sayHelloResponse" name="sayHelloResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="HelloServiceSoapBinding" type="impl:HelloService">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="sayHello">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="sayHelloRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded" />
</wsdl:input>
- <wsdl:output name="sayHelloResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://127.0.0.1:8080/axis/HelloService.jws" use="encoded" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="HelloServiceService">
- <wsdl:port binding="impl:HelloServiceSoapBinding" name="HelloService">
<wsdlsoap:address location="http://127.0.0.1:8080/axis/HelloService.jws" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
HttpConnection http = null;
try{
http = (HttpConnection)Connector.open(url, Connector.READ);
}catch(IOException ioe){
System.out.println("ioe:"+ioe.toString());
}
return http;InputStream is = null;
is = httpconn.openInputStream();
这里是获取流 需要先把流转为Document 对象,然后再对Document对象进行解析,需要用到xml解析包 public static Document getDocument(String url){
//声明一个Document
Document doc = new Document();
//声明一个XmlParaser
XmlParser xParser = null;
//声明一个NewXmlParase
NewXmlParase nXml = new NewXmlParase();
//获取输入流
InputStream is = nXml.getClass().getResourceAsStream(url);
//利用输入流为参数,转化为读流
InputStreamReader isr = NewXmlParase.getStreamByString(NewXmlParase.getUTFString(is));
try{
//实例化xParser
xParser = new XmlParser(isr);
//
doc.parse(xParser);
//将xParser置为空
xParser = null;
//捕获异常
}catch(Exception e){
xParser = null;
doc = null;
return null;
}
//返回doc
return doc;
}
另一种方法:
public static Document getDocument(InputStream is){
Document doc = new Document();
//声明一个XmlParaser
XmlParser xParser = null;
//利用输入流为参数,转化为读流
InputStreamReader isr = NewXmlParase.getStreamByString(NewXmlParase.getUTFString(is));
try{
xParser = new XmlParser(isr);
doc.parse(xParser);
xParser = null;
}catch(Exception ioe){
doc = null;
xParser = null;
return null;
}
return doc;
}用wsdl4j可以直接处理的 ,它是一个包
http://wsdl4j.sourceforge.net/downloads/
WSDLFactory wsdlFactory;
try {
wsdlFactory = WSDLFactoryImpl.newInstance();
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose",false);
wsdlReader.setFeature("javax.wsdl.importDocuments",true);
Definition def = wsdlReader.readWSDL(wsdlURL);
//显示结果
System.out.println("element: "+element);结果:element: null这是如何解决呢