0

我正在开发一个 Java Web 服务客户端项目。在其中,我必须将参数从 java 发送到 wsdl 实现者的相关 java 类。我必须使用的代码是:

private static SendSMSOutput sendSMS(tr.com.SomeProvider.sdp.mapping.generated.SendSMSInput requestPart) {
    tr.com.SomeProvider.sdp.wsdl.generated.SendMessage service = new tr.com.SomeProvider.sdp.wsdl.generated.SendMessage();
    tr.com.SomeProvider.sdp.wsdl.generated.SendMessagePort port = service.getSendMessagePort();
    return port.sendSMS(requestPart);
}

我必须将参数从主类发送到这个方法。

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"expirydate",
"messageclass",
"sdate",
"sender",
"shortnumber",
"srcmsisdn",
"nreq",
"toreceivers",
"messagebody"})

@XmlRootElement(name = "SendSMSInput")
public class SendSMSInput {

@XmlElement(name = "EXPIRY_DATE")
protected String expirydate;
@XmlElement(name = "MESSAGE_CLASS")
protected String messageclass;
@XmlElement(name = "S_DATE")
protected String sdate;
@XmlElement(name = "SENDER")
protected String sender;
@XmlElement(name = "SHORT_NUMBER", required = true)
protected String shortnumber;
@XmlElement(name = "SRC_MSISDN")
protected String srcmsisdn;
@XmlElement(name = "NREQ")
protected String nreq;
@XmlElement(name = "TO_RECEIVERS", required = true)
protected SendSMSInput.TORECEIVERS toreceivers;
@XmlElement(name = "MESSAGE_BODY", required = true)
protected SendSMSInput.MESSAGEBODY messagebody;

/**
 * Gets the value of the expirydate property.
 * 
 * @return
 *     possible object is
 *     {@link String }
 *     
 */
public String getEXPIRYDATE() {
    return expirydate;
}

/**
 * Sets the value of the expirydate property.
 * 
 * @param value
 *     allowed object is
 *     {@link String }
 *     
 */
public void setEXPIRYDATE(String value) {
    this.expirydate = value;
}

/**
 * Gets the value of the messageclass property.
 * 
 * @return
 *     possible object is
 *     {@link String }
 *     
 */
public String getMESSAGECLASS() {
    return messageclass;
}

/**
 * Sets the value of the messageclass property.
 * 
 * @param value
 *     allowed object is
 *     {@link String }
 *     
 */
public void setMESSAGECLASS(String value) {
    this.messageclass = value;
}

/**
 * Gets the value of the sdate property.
 * 
 * @return
 *     possible object is
 *     {@link String }
 *     
 */
public String getSDATE() {
    return sdate;
}

/**
 * Sets the value of the sdate property.
 * 
 * @param value
 *     allowed object is
 *     {@link String }
 *     
 */
public void setSDATE(String value) {
    this.sdate = value;
}

/**
 * Gets the value of the sender property.
 * 
 * @return
 *     possible object is
 *     {@link String }
 *     
 */
public String getSENDER() {
    return sender;
}

/**
 * Sets the value of the sender property.
 * 
 * @param value
 *     allowed object is
 *     {@link String }
 *     
 */
public void setSENDER(String value) {
    this.sender = value;
}

/**
 * Gets the value of the shortnumber property.
 * 
 * @return
 *     possible object is
 *     {@link String }
 *     
 */
public String getSHORTNUMBER() {
    return shortnumber;
}

/**
 * Sets the value of the shortnumber property.
 * 
 * @param value
 *     allowed object is
 *     {@link String }
 *     
 */
public void setSHORTNUMBER(String value) {
    this.shortnumber = value;
}

/**
 * Gets the value of the srcmsisdn property.
 * 
 * @return
 *     possible object is
 *     {@link String }
 *     
 */
public String getSRCMSISDN() {
    return srcmsisdn;
}

/**
 * Sets the value of the srcmsisdn property.
 * 
 * @param value
 *     allowed object is
 *     {@link String }
 *     
 */
public void setSRCMSISDN(String value) {
    this.srcmsisdn = value;
}

/**
 * Gets the value of the nreq property.
 * 
 * @return
 *     possible object is
 *     {@link String }
 *     
 */
public String getNREQ() {
    return nreq;
}

/**
 * Sets the value of the nreq property.
 * 
 * @param value
 *     allowed object is
 *     {@link String }
 *     
 */
public void setNREQ(String value) {
    this.nreq = value;
}

/**
 * Gets the value of the toreceivers property.
 * 
 * @return
 *     possible object is
 *     {@link SendSMSInput.TORECEIVERS }
 *     
 */
public SendSMSInput.TORECEIVERS getTORECEIVERS() {
    return toreceivers;
}

/**
 * Sets the value of the toreceivers property.
 * 
 * @param value
 *     allowed object is
 *     {@link SendSMSInput.TORECEIVERS }
 *     
 */
public void setTORECEIVERS(SendSMSInput.TORECEIVERS value) {
    this.toreceivers = value;
}

/**
 * Gets the value of the messagebody property.
 * 
 * @return
 *     possible object is
 *     {@link SendSMSInput.MESSAGEBODY }
 *     
 */
public SendSMSInput.MESSAGEBODY getMESSAGEBODY() {
    return messagebody;
}

/**
 * Sets the value of the messagebody property.
 * 
 * @param value
 *     allowed object is
 *     {@link SendSMSInput.MESSAGEBODY }
 *     
 */
public void setMESSAGEBODY(SendSMSInput.MESSAGEBODY value) {
    this.messagebody = value;
}


/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="message" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "message"
})
public static class MESSAGEBODY {

    @XmlElement(required = true)
    protected List<String> message;

    /**
     * Gets the value of the message property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the message property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getMessage().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link String }
     * 
     * 
     */
    public List<String> getMessage() {
        if (message == null) {
            message = new ArrayList<String>();
        }
        return this.message;
    }

}


/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="msisdn" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "msisdn"
})
public static class TORECEIVERS {

    @XmlElement(required = true)
    protected List<String> msisdn;

    /**
     * Gets the value of the msisdn property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the msisdn property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getMsisdn().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link String }
     * 
     * 
     */
    public List<String> getMsisdn() {
        if (msisdn == null) {
            msisdn = new ArrayList<String>();
        }
        return this.msisdn;
    }

}

}

据我了解,我必须根据 SendInput 发送参数。我想我必须创建这样一个有效负载,其中包含过期日期、消息类、sdate、发送者、短号、srcmsisdn、nreq、接收者和消息体。

我的问题是如何将这些参数作为一个发送到 SendSMSOutput 方法?提前致谢。

编辑:在文档中,soap 消息的外观如下:

<soap:Body>
    <sdp:SendSMSInput>
        <sdp:EXPIRY_DATE>250106121212</sdp:EXPIRY_DATE>
        <sdp:MESSAGE_CLASS>0</sdp:MESSAGE_CLASS>
        <sdp:S_DATE>200106121212</sdp:S_DATE>
        <sdp:SHORT_NUMBER>1905</sdp:SHORT_NUMBER>
        <sdp:SRC_MSISDN>123123123123</sdp:SRC_MSISDN>
        <sdp:TO_RECEIVERS>
            <sdp:msisdn>123123123123</sdp:msisdn>
            <sdp:msisdn>123123123123</sdp:msisdn>
        </sdp:TO_RECEIVERS>
        <sdp:MESSAGE_BODY>
            <sdp:message>MESSAGE BODY GOES HERE</sdp:message>
            <sdp:message>SECOND BODY GOES HERE</sdp:message>
        </sdp:MESSAGE_BODY>
    </sdp:SendSMSInput>
</soap:Body>
4

1 回答 1

0

您必须实例化一个类对象tr.com.SomeProvider.sdp.mapping.generated.SendSMSInput,填充其字段并将其转发给方法sendSMS。应该通过调用适当的构造函数以通常的方式进行实例化。您将通过调用setXXX(..)方法直接填充的大多数字段,除了 MESSAGEBODY 和 TORECEIVERS。您将以这种方式填充它们(TORECEIVERS 的示例,MESSAGEBODY 的示例):

//INSTANTIATE requestPart
...
SendSmsInput.TORECEIVERS receivers = new SendSmsInput.TORECEIVERS();
receivers.getMsisdn().add("value1");
receivers.getMsisdn().add("value2");
..
requestPart.setTORECEIVERS(receivers);
于 2012-11-29T07:40:32.373 回答