我正在使用Netbeans IDE,我正在从wsdl文件创建一个webservivce客户端。
Netbeans创建了所有类,我已经将webservice引用插入到jsp页面中,Netbeans生成了以下代码:
<%
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;
}
}
需要传递给'inputBody'的值将从URL字符串的参数值创建。我只需要知道如何转换它以便它被类接受。
任何帮助将不胜感激。
由于
答案 0 :(得分:1)
这将是一个新的PostcodeLookupRequest(),并在该实例上调用了setPostCode方法。