Add the Header element WebService WSDL to the header in soap settings

Source: Internet
Author: User
Tags sendmsg

Import java.net. url;
 
Import javax. xml. namespace. QNAME;
Import javax. xml. rpc. parametermode;
 
Import org. Apache. axis. Client. call;
Import org. Apache. axis. Client. Service;
Import org. Apache. axis. encoding. xmltype;
 
Import org. Apache. axis. Message. soapheaderelement;
Import javax. xml. Soap. soapelement;
 
Public class sendsmszop implements runnable {
Public String phones = NULL; // adfbcc
Public String MSG = NULL; // "test ";
 
Public int t_count = 0;
Public int tname = 0;

Public void run (){
// System. Out. println ("[TN:" + tname + "]" + t_count );
Long S = system. currenttimemillis ();
String r = send2zop (phones, MSG );
Long E = system. currenttimemillis ();
String time = (E-S)/1000 = 0? (E-S) + "millisecond" :( e-S)/1000 + "second" + (E-S) % 1000 + "millisecond ";
System. Out. println ("[TN:" + tname + "] P:" + phones + "St->" + time + ", R->" + r );
// System. Out. println ("St->" + time + ", R->" + r );
}
 
Private string send2zop (string phones, string MSG ){
String ret = NULL;
Try {

String username = "dkfj ";
String Password = "123456 ";
String namespace = "http://tempuri.org /";
String endpoint = "http: // 1.6.5.1/friend_ws/SES. asmx ";
 
Service = new service ();
Call call = NULL;
Call = (CALL) service. createcall ();
Call. settargetendpointaddress (new URL (endpoint ));
 
Call. setoperationname (New QNAME (namespace, "sendmsg "));
Call. addparameter (New QNAME (namespace, "rnos"), xmltype. xsd_string,
Parametermode. In );
Call. addparameter (New QNAME (namespace, "MSG"), xmltype. xsd_string,
Parametermode. In );
Call. setreturntype (xmltype. xsd_string );
 
Call. setusesoapaction (true );
Call. setsoapactionuri ("http://tempuri.org/SendMsg ");
 
Soapheaderelement element = new soapheaderelement (New QNAME (
Namespace, "validheader "));
Soapelement Se = element. addchildelement ("username ");
Se. addtextnode (username );
Se = element. addchildelement ("password ");
Se. addtextnode (password );
Call. addheader (element );
 
Ret = (string) Call. Invoke (new object [] {phones, MSG });
// System. Out. println (RET );
} Catch (exception e ){
E. printstacktrace ();
}
Return ret;
 
}

}
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.