java类期望Web服务请求的数据类型是什么?
我正在使用Netbeans IDE,并从wsdl文件创建WebServiceVCE客户端 Netbeans创建了所有类,我将webservice引用插入到jsp页面,Netbeans生成了以下代码:java类期望Web服务请求的数据类型是什么?,java,web-services,jakarta-ee,soap,netbeans,Java,Web Services,Jakarta Ee,Soap,Netbeans,我正在使用Netbeans IDE,并从wsdl文件创建WebServiceVCE客户端 Netbeans创建了所有类,我将webservice引用插入到jsp页面,Netbeans生成了以下代码: <% try { com.businessobjects.DataServicesServer service = new com.businessobjects.DataServicesServer(); com.businessobjects.RealTimeServices port
<%
try {
com.businessobjects.DataServicesServer service = new com.businessobjects.DataServicesServer();
com.businessobjects.RealTimeServices port = service.getRealTimeServices();
// TODO initialize WS operation arguments here
com.businessobjects.service.postcodelookup.input.PostcodeLookupRequest inputBody = null;
// TODO process result here
com.businessobjects.service.postcodelookup.output.PostcodeLookupReply result = port.postcodeLookup(inputBody);
out.println("Result = "+result);
} catch (Exception ex) {
// TODO handle custom exceptions here
}
%>
从这段代码中,我了解到我需要为“inputBody”设置一个值(当前默认设置为null),但我不知道要使用什么数据类型
这里是PostcodeLookupReply.class中的代码
package com.businessobjects.service.postcodelookup.input;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="postcode">
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <maxLength value="7"/>
* </restriction>
* </simpleType>
* </element>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"postcode"
})
@XmlRootElement(name = "postcodeLookupRequest")
public class PostcodeLookupRequest {
@XmlElement(required = true)
protected String postcode;
/**
* Gets the value of the postcode property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getPostcode() {
return postcode;
}
/**
* Sets the value of the postcode property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setPostcode(String value) {
this.postcode = value;
}
}
package com.businessobjects.service.postcodelookup.input;
导入javax.xml.bind.annotation.XmlAccessType;
导入javax.xml.bind.annotation.XmlAccessorType;
导入javax.xml.bind.annotation.xmlement;
导入javax.xml.bind.annotation.XmlRootElement;
导入javax.xml.bind.annotation.XmlType;
/**
*匿名复杂类型的Java类。
*
*以下架构片段指定此类中包含的预期内容。
*
*
*complexType>
*complexContent>
*限制基数=”{http://www.w3.org/2001/XMLSchema}任何类型“>
*序列>
*元素名称=“邮政编码”>
*simpleType>
*限制基数=”{http://www.w3.org/2001/XMLSchema}字符串“>
*maxLength值=“7”/>
*/限制>
*/simpleType>
*/element>
*/顺序>
*/限制>
*/complexContent>
*/complexType>
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name=),比例={
“邮政编码”
})
@XmlRootElement(name=“postcodeLookupRequest”)
公共类PostcodeLookupRequest{
@XmlElement(必需=true)
受保护的字符串邮政编码;
/**
*获取postcode属性的值。
*
*@返回
*可能的对象是
*{@link String}
*
*/
公共字符串getPostcode(){
返回邮政编码;
}
/**
*设置“邮政编码”属性的值。
*
*@param值
*允许的对象是
*{@link String}
*
*/
public void setPostcode(字符串值){
this.postcode=值;
}
}
需要传递给“inputBody”的值将根据URL字符串中的参数值创建。我只需要知道什么以及如何转换它,以便它被类接受
任何帮助都将不胜感激
谢谢这将是一个新的PostcodeLookupRequest(),在该实例上调用setPostCode方法。为什么不引用您的wsdl文件?您可以使用soapui获取输入请求格式,在代码中生成该请求消息,并在inputBody中提供该消息。这就是您的要求吗?您可以发布RealTimeServices.postcodeLookup的签名吗?Tony-我该怎么做?转到文件->新建soapui项目,浏览您的wsdl文件或在那里提供wsdl url,选中“创建请求消息”,然后单击“确定”。如果在操作中没有遇到错误,将生成请求消息结构。非常确定我尝试了这个,但没有结果。要确认,您的意思是:com.businessobjects.service.postcodelookup.input.PostcodeLookupRequest req=new com.businessobjects.service.postcodelookup.input.PostcodeLookupRequest();要求设置邮政编码(“ABC”);com.businessobjects.service.postcodelookup.input.PostcodeLookupRequest inputBody=req;工作代码为:PostcodeLookupRequest pReq=new PostcodeLookupRequest();预设邮政编码(“A12ABC”);Postcode LookupRequest inputBody=pReq;PostcodeLookupReply pReply=postcodeLookup(inputBody);Postcode LookupRequest inputBody=pReq;-那句话毫无意义。但是是的,这应该行得通。