简体   繁体   English

Java-以编程方式从给定的WSDL创建SOAP

[英]Java - create SOAP From a given WSDL programatically

Most web service provide a WSDL Link. 大多数Web服务都提供WSDL链接。 When you pass this WSDL link to Eclipse it generates the JAVA coded Client. 当您将此WSDL链接传递给Eclipse时,它将生成JAVA编码的客户端。 When you Pass the WSDL Link to SOAPUI It generates the SOAP envelope. 当您将WSDL链接传递给SOAPUI时,它将生成SOAP信封。

the question is: 问题是:

is there an API in java that will allow me to generate the SOAP XML programatically? Java中是否有API,可以让我以编程方式生成SOAP XML?

Something like this : 像这样的东西:

WSDLReader re = new WSDLReader("WSDLURL");
String s = re.getWSDL();

ADDITIONAL INFO: I found an API that does something similar, Its called SOAP-WS. 其他信息:我发现有一个类似的API,称为SOAP-WS。 but the example given in the document is maven based. 但是文档中给出的示例是基于Maven的。 I want it in normal JAVA, ie non-maven base. 我想要在普通的JAVA中,即非Maven基础。

I have solved this problem with the following link : 我已经通过以下链接解决了这个问题:
http://www.membrane-soa.org/create-soap-request.htm http://www.membrane-soa.org/create-soap-request.htm
This IS the answer to my question. 这是我的问题的答案。 just download the required JARs, include them in your project and use the attached example. 只需下载所需的JAR,将其包含在您的项目中,然后使用随附的示例。 after that , if you pass a WSDL file the program will generate the required SOAP request. 之后,如果您传递WSDL文件,程序将生成所需的SOAP请求。 This is for anyone that happens to have the same problem as i did. 这适用于碰巧遇到与我相同的问题的任何人。 :) :)

I am against of messing the philosphy with coding but. 我反对将哲学与编码混为一谈。

You should know that WSDL use XML for its own purpose. 您应该知道WSDL出于自身目的使用XML。 So on this fact, you can dwonload a XML file from given web adres. 因此,就此事实而言,您可以从给定的Web广告中下载XML文件。 Then XML file do not differ from any other text file. 然后,XML文件与任何其他文本文件都没有不同。 So on this fact we can say thay problem is reduced do downloading and reading a text file. 因此,基于这个事实,我们可以说减少了下载和读取文本文件的麻烦。

To allow that you can use Java NIO , ( example ) to download the file. 为此,您可以使用Java NIO示例 )下载文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM