【问题标题】:Creating SOAP request from wsdl从 wsdl 创建 SOAP 请求
【发布时间】:2014-05-22 11:08:29
【问题描述】:

我需要为来自 wsdl 的一项操作创建 SOAP 请求 xml。我研究并尝试了博客“Java: Get Sample Request XML from wsdl”的解决方案,但在“WsdlProject project = new WsdlProject();”行中出现异常“java.lang.NoClassDefFoundError: org/fife/ui/rtextarea/RTextArea”

我导入了最新的 jars (soapui-xmlbeans-4.5.0,wsdl-xmlbeans-1.1,soapui-4.5.0) 但仍然抛出异常。任何人都可以“http://www.soapui.org/repository/eviware/”请建议我该如何纠正它。除了这个,我还有其他方法可以采取吗?

提前致谢!!

【问题讨论】:

  • 使用 SOAPUI 工具......它会帮助你......soapui.org
  • 感谢您的回复,但 SoapUI 将是一项手动任务。我编写了代码来从 wsdl 中提取 Soap 请求 xml。你能告诉我如何实现这一目标。
  • 我使用下面的代码 WsdlProject project = new WsdlProject; WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, ""); WsdlInterface wsdl = wsdls[0]; for (com.eviware.soapui.model.iface.Operation 操作 : wsdl.getOperationList()) { WsdlOperation wsdlOperation = (WsdlOperation) 操作; System.out.println("OP:"+wsdlOperation.getName()); System.out.println("请求:"); System.out.println(wsdlOperation.createRequest(true)); System.out.println("响应:"); System.out.println(wsdlOperation.createResponse(true)); } }

标签: java xml web-services soap wsdl


【解决方案1】:
1. Create a Java Project: File->New->Other->Java Project. (TestWSDL)
2. Create a WSDL File: File->New->Other->Web Services->WSDL File-> Name the file->Next->finish. (NewWSDLFile.wsdl)
3. Modify the WSDL File: Open NewWSDLFile.wsdl and replace all its content by your desired WSDL file.Save it. (Suppose I have saved my desired wsdl file at D:\sampleWSDL.xml, which i want to convert. Open this xml file using Notepad++,copy all its content and paste it to NewWSDLFile.wsdl)
4. Create Web Service Client: File->New->Other->Web Services->Web Service Client->Next->Browse Service definition and show the path of the NewWSDLFile.wsdl file we created at step 2 ->OK-> 5. Click Client Project(blue colored link at right) and set it to the project we created at step
6. Press Next -> Set Output Folder->Finish.
7. You will have all the converted Java files at the folder you set at step 5.

【讨论】:

  • 感谢桑巴夫!我明白你在说什么,但我的要求不是那样。我有我的 wsdl url,其中包含端点信息。要求:我收到来自 Web 服务调用的响应。我需要从该响应中获取一些值并将其添加到另一个 Web 服务 Soap req 并再次进行 Web 服务调用。所以为了给soap req添加新值,我需要得到它完整的soap requst xml。这就是为什么我问如何从wsdl获取soap请求xml。我不能使用SoapUI,因为它每次都是动态的,所以我需要写一个java代码。倒是请你告诉我如何才能做到这一点。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-13
  • 2017-01-17
  • 1970-01-01
  • 2021-06-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多