dim url,userName,PassWord,Mobile,Code,DisPlayNbr,vReplay
url = "http://service.winic.org:8813/Service.asmx"
userName = "帐号"
PassWord = "密码"
Mobile = "手机号码"
Code = "内容"
DisPlayNbr=""
vReplay="2"
function SendVoiceForCode(userName,PassWord,Mobile,Code,DisPlayNbr,vReplay)
SoapRequest="
"& _
"
"& _
"
"& _
"
"& _
"
"&userName&"
"& _
"
"&PassWord&"
"& _
"
"&Mobile&"
"& _
""&Code&"
"& _
"
"&DisPlayNbr&"
"& _
"
"&vReplay&"
"& _
"
"& _
"
"& _
"
"
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:8813/Service.asmx"
xmlhttp.setRequestHeader "Content-Length",LEN(SoapRequest)
xmlhttp.setRequestHeader "SOAPAction", "http://tempuri.org/SendMessages"
xmlhttp.Send(SoapRequest)
If xmlhttp.Status = 200 Then
Set xmlDOC = server.CreateObject("MSXML.DOMDocument") <
xmlDOC.load(xmlhttp.responseXML)
SendVoiceForCode=xmlDOC.documentElement.selectNodes("//SendVoiceForCodeResult")(0).text
Set xmlDOC = nothing
Else
SendVoiceForCode=xmlhttp.Status&" "
SendVoiceForCode=xmlhttp.StatusText
End if
Set xmlhttp = Nothing
end function
response.write SendVoiceForCode(userName,PassWord,Mobile,Code,DisPlayNbr,vReplay)
$client = new SoapClient('http://service2.winic.org/service.asmx?WSDL');
$client->soap_defencoding = 'utf-8';
$client->decode_utf8 = false;
$client->xml_encoding = 'utf-8';
$param = array('userName'=>'帐号', 'PassWord'=>'密码','Mobile'=>'接收的手机号',
'Code'=>'语音验证码','DisPlayNbr'=>'主显号码', 'vReplay'=>'是否重听');
$result = $client->__Call("SendVoiceForCode", array( $param ));
if (is_soap_fault($result))
{
trigger_error("SOAP Fault: (faultcode: {$result->faultcode},
faultstring: {$result->faultstring})", E_USER_ERROR);
}
else
{
$data = $result->SendVoiceForCodeResult;
print_r($data);
}
//用C#编辑器创建Form 引用soap文件
protected void bntSendNote_Click(object sender, EventArgs e)
{
WebService.Service1 ws = new WebService.Service1();
txtResult.Text = ws.SendVoiceForCode(txt_userName.Text, txt_PassWord.Text, txt_Mobile.Text, txt_Code.Text,txt_DisPlayNbr.Text, txt_vReplay.Text );
}
private static String getSoapSendVoiceForCode(String userName,String PassWord,String Mobile,String Code,String DisPlayNbr,String vReplay)
{
try
{
String soap = "";
soap = "
"
+"
"
+"
"
+"
"
+"
"+userName+"
"
+"
"+PassWord+"
"
+"
"+Mobile+"
"
+""+Code+"
"
+"
"+DisPlayNbr+"
"
+"
"+vReplay+"
"
+"
"
+"
"
+"
";
return soap;
}
catch (Exception ex)
{
ex.printStackTrace();
return null;
}
}
private static InputStream getSoapInputStream(String userName,String PassWord,String Mobile,String Code,String DisPlayNbr,String vReplay)throws Exception
{
URLConnection conn = null;
InputStream is = null;
try
{
String soap=getSoapSendVoiceForCode(String userName,String PassWord,String Mobile,String Code,String DisPlayNbr,String vReplay);
if(soap==null)
{
return null;
}
try{
URL url=new URL("http://service.winic.org:8813/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","service2.winic.org");
conn.setRequestProperty("SOAPAction","\"http://tempuri.org/SendVoiceForCode\"");
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 sendSms(String userName,String PassWord,String Mobile,String Code,String DisPlayNbr,String vReplay)
{
String result = "-12";
try
{
Document doc;
DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db=dbf.newDocumentBuilder();
InputStream is=getSoapInputStream(userName,PassWord,Mobile,Code,DisPlayNbr,vReplay);
if(is!=null){
doc=db.parse(is);
NodeList nl=doc.getElementsByTagName("SendVoiceForCodeResult");
Node n=nl.item(0);
result=n.getFirstChild().getNodeValue();
is.close();
}
return result;
}
catch(Exception e)
{
System.out.print("SmsSoap.SendVoiceForCode error:"+e.getMessage());
return "-12";
}
}
}
protected void bntSendNote_Click(object sender, EventArgs e)
{
WebService.Service1 ws = new WebService.Service1();
txtResult.Text = ws.SendVoiceForCode(txt_userName.Text, txt_PassWord.Text, txt_Mobile.Text, txt_Code.Text,txt_DisPlayNbr.Text, txt_vReplay.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:8813/Service.asmx/SendVoiceForCode?userName='+userName.Text+'&PassWord='+PassWord.Text+'&Mobile='+Mobile.Text+'&Code='+Code.Text+'&DisPlayNbr='+DisPlayNbr.Text+'&vReplay'+vReplay.Text+');
int basefd;
char *hostname = "service.winic.org:8813";
char *send_sms_uri = "/Service.asmx/SendVoiceForCode";
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 send_sms(char *userName, char *PassWord, char *Mobile, char *Code, char *DisPlayNbr, char *vReplay)
{
char params[MAXPARAM + 1];
char *cp = params;
sprintf(cp,"userName=%s&PassWord=%s&Mobile=%s&Code=%s&DisPlayNbr=&vReplay=%s", userName, PassWord, Mobile, Code, DisPlayNbr, vReplay);
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 = "xx";
char *PassWord "xx";
char *Mobile ="13222334512";
char *Code "验证码是:1 2 3 4 5 6";
char *DisPlayNbr = "";
char *vReplay = "2";
send_sms(userName, PassWord, Mobile, Code, DisPlayNbr, vReplay);
printf("send the message is success\n");
close(basefd);
exit(0);
}