www.pudn.com > WAPPUSHJAVA.rar > Push.java


package unicompush.Send;
import java.util.*;
import java.sql.*;
import unicompush.db.*;
import unicompush.util.*;
import unicompush.Info.*;
import javax.activation.*;
import javax.mail.*;
import java.net.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
/**
 * 

Title: PUSH网关(适合联通华友平台)

*

Description: 仅以此系统献给奋斗在联通WAP业务前线的同事们

*

Copyright: Copyright (c) 2004

*

Company: Entel Communication Co,Ltd

* @author Reedy * @version 1.0 */ public class Push { private static String LogFile = "Send"; public Push(){} public static int PushMsg(SendInfo info) { try{ // Build the call. Call call = new Call (); //设置调用的方法名 call.setMethodName("pushMSG"); //设置编码风格 call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC); //设置方法调用的参数 Vector params = new Vector (); params.addElement (new Parameter("fromUserMobile", String.class, new String (info.getFromMobile()), null)); params.addElement (new Parameter("toUserMobile", String.class, new String (info.getToMobile()), null)); params.addElement (new Parameter("alertTitle", String.class, new String (info.getalertTitle()), null)); params.addElement (new Parameter("alertURL", String.class, new String (info.getalertUrl()), null)); params.addElement (new Parameter("needBilling", Boolean.class, new Boolean (false), null)); call.setParams(params); //发送RPC请求 URL url = new URL("http://211.94.69.247/pushsender/services/PushSIServicePort"); Response resp = call.invoke (url,""); if (resp.generatedFault ()) { //远程调用出错处理 Fault fault = resp.getFault (); Logger.writeLog("push error--the call failed--Fault Code=" + fault.getFaultCode () + "--Fault String=" + fault.getFaultString (),LogFile); return -1; } else { //调用成功,获取返回值 Parameter result = resp.getReturnValue (); int finalresult = -1; try{ String r = (String)result.getValue().toString(); Logger.writeLog(">>" + r,LogFile); if ((r.indexOf("1000"))>-1||(r.toString().indexOf("1001")>-1)) finalresult = 0; } catch(Exception e) { finalresult = -1; } return finalresult; } } catch(Exception e) { Logger.writeLog("push error"+e.getMessage(),LogFile); return -1; } } }