英文:
Using a SOAP artifact in Java
问题
我已经到处搜索了,但找不到关于这个的简单示例。我需要从我的Java应用程序中使用SOAP调用Web服务。我已经运行了从WSDL创建所有Java构件的工具。假设其中一个名为“Customer”,以下是前几行:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Customer", propOrder = { "id" })
public class Customer {
我假设我首先会创建一个新的Customer对象,并设置所有所需的属性。我需要知道的是如何将该对象封装成一个SOAP信封(?)并将其传递给服务。我还有用于提交的构件,比如“SubmitCustomer”,但同样我不确定如何使用我的Customer对象继续操作。
我确信这是一个基本问题,但在搜索中我能找到的都是关于如何创建自己的XML的示例,或者基本的“如何开始使用SOAP”,或者如何生成构件,仅此而已。如果有人能指点我一个好的资源,那就太好了。
英文:
I've been searching all over and I can't find a simple example for this. I need to call a Web service from my Java application using SOAP. I've run the utility to create all the Java artifacts from the WSDL. Let's say one is called "Customer", and these are the first few lines:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Customer", propOrder = { "id" })
public class Customer {
I assume that I start by creating a new Customer object and setting all the attributes I need. What I need to know is how to take that object and pass it to the service as a SOAP envelope(?). I also have artifacts for submit, like "SubmitCustomer", but again I'm not sure how to take my Customer object and keep going with it.
I'm sure this is a basic question, but all I've been able to find in my searches are examples of creating your own XML, or basic "how to get started with SOAP", or how to generate artifacts, but that's all. If someone can point me to a good resource, that would be great.
答案1
得分: 1
在生成的类中,必须有一个类扩展自javax.xml.ws.Service
。查看这个类,寻找一个被@WebEndpoint
注解标记的方法。打开包含该方法返回类型定义的文件。在那里,你会找到对应于WSDL操作的方法。
英文:
Among generated classes must be one extends javax.xml.ws.Service
.<br>
Look through this class to find a method annotated with @WebEndpoint
.<br>
Open file with definition of return type of this method.<br>
There you will find methods correspond to WSDL operations.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论