日期:2014-05-19  浏览次数:20676 次

目前项目用到短信接口,只有一个WSDL文件,怎么写一个客服端发送短信
MsgService.java


package org.example.msgservice;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;

/**
 * This class was generated by the JAX-WS RI. JAX-WS RI 2.1.3-hudson-390-
 * Generated source version: 2.0
 * 
 */
@WebService(name = "MsgService", targetNamespace = "http://www.example.org/MsgService/")
public interface MsgService {

/**

* @param content
* @param checkcode
* @param spid
* @param date
* @param mobile
* @return returns java.lang.String
*/
@WebMethod(action = "http://www.example.org/MsgService/NewOperation")
@WebResult(name = "status", targetNamespace = "")
@RequestWrapper(localName = "sendMsg", targetNamespace = "http://www.example.org/MsgService/", className = "org.example.msgservice.SendMsg")
@ResponseWrapper(localName = "sendMsgResponse", targetNamespace = "http://www.example.org/MsgService/", className = "org.example.msgservice.SendMsgResponse")
public String sendMsg(
@WebParam(name = "spid", targetNamespace = "") String spid,
@WebParam(name = "date", targetNamespace = "") String date,
@WebParam(name = "checkcode", targetNamespace = "") String checkcode,
@WebParam(name = "mobile", targetNamespace = "") String mobile,
@WebParam(name = "content", targetNamespace = "") String content);

}

MsgServiceSOAPImpl.java


package org.example.msgservice;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;

import sun.misc.BASE64Encoder;

import com.test.Demo;

@javax.jws.WebService(endpointInterface = "org.example.msgservice.MsgService", targetNamespace = "http://www.example.org/MsgService/", serviceName = "MsgService", portName = "MsgServiceSOAP")
public class MsgServiceSOAPImpl {

public String sendMsg(String spid, String date, String checkcode,
String mobile, String content) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Not implemented yet.");
}
}
ObjectFactory.java


package org.example.msgservice;

import javax.xml.bind.annotation.XmlRegistry;

/**
 * This object contains factory methods for each Java content interface and Java
 * element interface generated in the org.example.msgservice package.
 * <p>
 * An ObjectFactory allows you to programatically construct new instances of the
 * Java representation for XML content. The Java representation of XML content
 * can consist of schema derived interfaces and classes representing the binding
 * of schema type definitions, element declarations and model groups. Factory
 * methods for each of these are provided in this