dim url,uid,pwd,tos,msg
url = "http://service.winic.org:8065/service.asmx"
uid = "帐号"
pwd = "密码"
tos = "手机号码"
Title = "彩信标题(UTF-8=>Base64)"
msg = "图片内容(Base64),图片格式(JPG,GIF),文字内容(Base64),本帧播放时间|图片内容(Base64),图片格式(JPG,GIF),文字内容(Base64),本帧播放时间"
function SendMMS_NEW(uid,pwd,tos,msg,otime)
SoapRequest="
"& _
"
"& _
"
"& _
"
"& _
"
"&uid&"
"& _
"
"&pwd&"
"& _
"
"&tos&"
"& _
"
"&Title&"
"& _
"
"&msg&"
"& _
"
"& _
"
"& _
"
"& _
"
"
Set xmlhttp = server.CreateObject("Msxml2.XMLHTTP")
xmlhttp.Open "POST",url,false
xmlhttp.setRequestHeader "Content-Type", "text/xml;charset=utf-8"
xmlhttp.setRequestHeader "HOST","service.winic.org"
xmlhttp.setRequestHeader "Content-Length",LEN(SoapRequest)
xmlhttp.setRequestHeader "SOAPAction", "http://tempuri.org/SendMMS_NEW"
xmlhttp.Send(SoapRequest)
If xmlhttp.Status = 200 Then
Set xmlDOC = server.CreateObject("MSXML.DOMDocument")
xmlDOC.load(xmlhttp.responseXML)
SendMMS_NEW=xmlDOC.documentElement.selectNodes("//SendMMS_NEWResult")(0).text
Set xmlDOC = nothing
Else
SendMMS_NEW=xmlhttp.Status&" "
SendMMS_NEW=xmlhttp.StatusText
End if
Set xmlhttp = Nothing
end function
response.write SendMMS_NEW(uid,pwd,tos,msg,otime)
$client = new SoapClient('http://service.winic.org:8065/service.asmx?WSDL');
$client->soap_defencoding = 'utf-8';
$client->decode_utf8 = false;
$client->xml_encoding = 'utf-8'
$param = array('userName'=>'帐号', 'PassWord'=>'密码','Mobile'=>'接收短信的手机号','Title'=>'彩信标题(UTF-8=>Base64)'
'MMS_Content'=>'图片内容(Base64),图片格式(JPG,GIF),文字内容(Base64),本帧播放时间|图片内容(Base64),图片格式(JPG,GIF),文字内容(Base64),本帧播放时间'
,'SendTime'=>'');
$result = $client->__Call("SendMMS_NEW", array( $param ));
if (is_soap_fault($result))
{
trigger_error("SOAP Fault: (faultcode: {$result->faultcode},
faultstring: {$result->faultstring})", E_USER_ERROR);
}
else
{
$data = $result->SendMMS_NEWResult;
print_r($data);
}
//用C#编辑器创建Form 引用soap文件
protected void bntSendNote_Click(object sender, EventArgs e)
{
WebService.Service1 ws = new WebService.Service1();
txtResult.Text = ws.SendMMS_NEW(txtUID.Text, txt_PWD.Text, txtSmsmob.Text, txtTitle.Text, txtSms.Text, "");
}
public class smsService {
public static void main(String[] args) throws Exception {
SendMMS_NEW("帐号密码","密码","13301156525","彩信标题(Base64)","图片内容(Base64),图片格式(JPG,GIF),文字内容(Base64),本帧播放时间","");
}
private static String getSoapSendMMS_NEW(String userid,String pass,String mobiles,String title,String msg,String SendTime)
{
try
{
String soap = "";
soap = "
"
+"
"
+"
"
+"
"
+"
"+userid+"
"
+"
"+pass+"
"
+"
"+mobiles+"
"
+"
"+title+"
"
+"
"+msg+"
"
+"
"+SendTime+"
"
+"
"
+"
"
+"
";
return soap;
}
catch (Exception ex)
{
ex.printStackTrace();
return null;
}
}
private static InputStream getSoapInputStream(String userid,String pass,String mobiles,String title,String msg,String SendTime)throws Exception
{
URLConnection conn = null;
InputStream is = null;
try
{
String soap=getSoapSendMMS_NEW(userid,pass,mobiles,title,msg,time);
if(soap==null)
{
return null;
}
try{
URL url=new URL("http://service.winic.org:8065/service.asmx");
conn=url.openConnection();
conn.setUseCaches(false);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestProperty("Content-Length", Integer.toString(soap.length()));
conn.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
conn.setRequestProperty("HOST","service.winic.org");
conn.setRequestProperty("SOAPAction","\"http://tempuri.org/SendMMS_NEW\"");
OutputStream os=conn.getOutputStream();
OutputStreamWriter osw=new OutputStreamWriter(os,"utf-8");
osw.write(soap);
osw.flush();
}catch(Exception ex){
System.out.print("SmsSoap.openUrl error:"+ex.getMessage());
}
try{
is=conn.getInputStream();
}catch(Exception ex1){
System.out.print("SmsSoap.getUrl error:"+ex1.getMessage());
}
return is;
}
catch(Exception e)
{
System.out.print("SmsSoap.InputStream error:"+e.getMessage());
return null;
}
}
//发送彩信
public static String SendMMS_NEW(String userid,String pass,String mobiles,String title,String msg,String SendTime)
{
String result = "-12";
try
{
Document doc;
DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db=dbf.newDocumentBuilder();
InputStream is=getSoapInputStream(userid,pass,mobiles,title,msg,time);
if(is!=null){
doc=db.parse(is);
NodeList nl=doc.getElementsByTagName("SendMMS_NEWResult");
Node n=nl.item(0);
result=n.getFirstChild().getNodeValue();
is.close();
}
return result;
}
catch(Exception e)
{
System.out.print("SmsSoap.SendMMS_NEW error:"+e.getMessage());
return "-12";
}
}
}
protected void bntSendNote_Click(object sender, EventArgs e)
{
WebService.Service1 ws = new WebService.Service1();
txtResult.Text = ws.SendMMS_NEW(txtUID.Text, txt_PWD.Text, txtSmsmob.Text, txtTitle.Text, txtSms.Text, "");
}
// 注意引用 uses comobj
//_________________________________HTTP通信函数返回信息
function HTTPwebservice(url:string):string;
var
responseText: WideString;
xmlHttp: OLEVariant;
begin
try
xmlHttp:=CreateOleObject('Msxml2.XMLHTTP');
xmlHttp.open('GET',url,false);
xmlHttp.send();
responseText:=xmlHttp.responseText;
if xmlHttp.status='200' then
begin
HTTPwebservice:=responseText;
end;
xmlHttp := Unassigned;
except
exit;
end;
end;
//______________________________
//使用时调用即可
bdata:=HTTPwebservice(http://service.winic.org:8065/service.asmx/SendMMS_NEW?userName='+uid.Text+'&PassWord='+pwd.Text+'&Mobile='+tos.text+'&Title='+Title.text+'&MMS_Content='+msg.text+'&sendtime='');
int basefd;
char *hostname = "http://service.winic.org:8065";
char *send_sms_uri = "/service.asmx/SendMMS_NEW";
ssize_t http_post(char *page, char *poststr)
{
char sendline[MAXLINE + 1], recvline[MAXLINE + 1];
ssize_t n;
snprintf(sendline, MAXSUB,
"POST %s HTTP/1.0\r\n"
"Host: %s\r\n"
"Content-type: application/x-www-form-urlencoded\r\n"
"Content-length: %zu\r\n\r\n"
"%s", page, hostname, strlen(poststr), poststr);
write(basefd, sendline, strlen(sendline));
while ((n = read(basefd, recvline, MAXLINE)) > 0) {
recvline[n] = '\0';
printf("%s", recvline);
}
return n;
}
ssize_t SendMMS_NEW(char *userName, char *PassWord, char *Mobile, char *Title, char *MMS_Content, char *sendtime)
{
char params[MAXPARAM + 1];
char *cp = params;
sprintf(cp,"userName=%s&PassWord=%s&Mobile=%s&Title=%s&MMS_Content=%s&sendtime=", userName, PassWord, Mobile, Title, MMS_Content, sendtime);
return http_post(send_sms_uri, cp);
}
int socked_connect(char *arg)
{
struct sockaddr_in their_addr = {0};
char buf[1024] = {0};
char rbuf[1024] = {0};
char pass[128] = {0};
struct hostent *host = NULL;
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
if(sockfd<0)
{
printf ("create the sockfd is failed\n");
return -1;
}
if((host = gethostbyname(arg))==NULL)
{
printf("Gethostname error, %s\n");
return -1;
}
memset(&their_addr, 0, sizeof(their_addr));
their_addr.sin_family = AF_INET;
their_addr.sin_port = htons(80);
their_addr.sin_addr = *((struct in_addr *)host->h_addr);
if(connect(sockfd,(struct sockaddr *)&their_addr, sizeof(struct sockaddr)) < 0)
{
close(sockfd);
return -1;
}
printf ("connect is success\n");
return sockfd;
}
int main(void)
{
struct sockaddr_in servaddr;
char str[50];
sockfd = socket(AF_INET, SOCK_STREAM, 0);
bzero(&servaddr, sizeof(servaddr));
servaddr.sin_addr =*(hostname);
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(80);
inet_pton(AF_INET, str, &servaddr.sin_addr);
connect(sockfd, (SA *) & servaddr, sizeof(servaddr));
#endif
if((basefd= socked_connect(hostname))==-1)
{
printf("connect is failed\n");
return -1;
}
printf("basefd is =%d\n",basefd);
char *userName = "xxx";
char *PassWord = "xxx";
char *Mobile = "18000000000";
char *Title = "18000000000";
char *MMS_Content = "你的验证码为:123456";
char *sendtime = "";
SendMMS_NEW(userName, PassWord, Mobile, Title, MMS_Content, sengtime);
printf("send the message is success\n");
close(basefd);
exit(0);
}