在网上看到如下一段代码,是关于联通wap push的java源代码,编译无法通过,是因为缺少unicompush这个包,h这个包在哪里可以获得!
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.*;
/**
* <p>Title: PUSH网关(适合联通华友平台)</p>
* <p>Description: 仅以此系统献给奋斗在联通WAP业务前线的同事们</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: Entel Communication Co,Ltd</p>
* @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;
}}}
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.*;
/**
* <p>Title: PUSH网关(适合联通华友平台)</p>
* <p>Description: 仅以此系统献给奋斗在联通WAP业务前线的同事们</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: Entel Communication Co,Ltd</p>
* @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;
}}}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货