用asp如何开发wap push? |
| 作者:佚名 来源:转载 发布时间:2007-1-19 9:04:56 |
|
对于WAP PUSH服务,CP/SP需要向中国联通申请该类服务,并且CP/SP所提供的WAP PUSH内容所在的服务器能够与中国联通的 Openwave PUSH Server连通,连接方式分为内网连接和公网连接两种方式,由CP/SP根据自身实际情况选择连接方式。Openwave PUSH Server分别位于北京、上海两地,CP/SP根据就近原则选择需要连接的Openwave PUSH Server。CP/SP需要向中国联通提交内容应用服务器的主域名或IP地址。 北京Openwave PUSH SERVER的地址为: http://211.94.69.231:9001/pap(公网) http://10.2.17.66:9001/pap(内网) 上海Openwave PUSH SERVER的地址为: http://211.95.66.70:9001/pap(公网) http://10.95.17.66:9001/pap(内网)。 下面以向北京Openwave PUSH SERVER发送请求为例说明如何提供WAP PUSH服务: /* * Title: WAP Push Library Service Indication Payload Example * Description: A basic Push Submission example using a * Service Indication payload */ import java.io.IOException; import java.io.FileNotFoundException; import java.net.MalformedURLException; import java.net.URL; import com.openwave.wappush.*; public class ServiceInd { //Constants used in this example. static final String address = "手机标识" + "/TYPE=USER@gatewaybj.uni-info.com.cn"; static final String ppgAddress = "http://211.94.69.231:9001/pap"; static final String SvcIndURI = "http://devgate2.openwave.com/cgi-bin/mailbox.cgi"; static URL ppgURL = null; static URL siURI = null; public void SubmitMsg() throws WapPushException, IOException, MalformedURLException { //Instantiate and initialize the Pusher object. Pusher ppg = new Pusher(ppgURL); ppg.initialize(); //Instantiate the Service Indication object. //This is the text string to send to the client device. String alertText = "Mobile Mail: New message!"; ServiceIndication serviceIndication = new ServiceIndication(alertText); //Set the URI for this SI. serviceIndication.setHref(siURI); //Add some optional information to the SI. ServiceIndicationInfo info = new ServiceIndicationInfo("Mailbox", "Full"); info.AddInfoBlock("ReadMessages", "All"); serviceIndication.setInfo(info); //Set the Service Indication action to signal-high. serviceIndication.setAction(ServiceIndicationAction.signalHigh); //Add some optional time information. serviceIndication.setExpires( new DateTime(2004, 6, 15, 12, 0, 1)); serviceIndication.setCreated( new DateTime("2002-06-15T12:00:00Z")); //Instantiate the push message object and set some //optional information. PushMessage pushMessage = new PushMessage(pushID, address); pushMessage.setDeliverBeforeTimestamp(new DateTime("2004-06-15T12:00:01Z")); //Instantiate a MimeEntity and add the PushMessage //and ServiceIndication objects. MimeEntity me = new MimeEntity(); me.addEntity(pushMessage); me.addEntity(serviceIndication); //Send the push message PushResponse pushResponse = (PushResponse) ppg.send(me); //Read some information from the response. System.out.println("reply-Time = " + pushResponse.getReplyTime()); System.out.println("response-result-code = " + pushResponse.getResultCode()); System.out.println("response-result-desc = " + pushResponse.getResultDesc()); }//SubmitMsg() public static void main(String[] args) throws WapPushException, IOException { try { ppgURL = new URL(ppgAddress); siURI = new URL(SvcIndURI); ServiceInd si = new ServiceInd(); si.SubmitMsg(); } //Handle possible exceptions. catch (BadMessageException exception) { System.out.println("*** ERROR - bad message exception"); BadMessageResponse response = exception.getResponse(); System.out.println("*** ERROR = " + response.getBadMessageFragment()); } catch (WapPushException exception) { System.out.println("*** ERROR - WapPushException (" + exception.getMessage() + ")"); } catch (FileNotFoundException exception) { System.out.println("*** ERROR - input file not found"); } catch (MalformedURLException exception) { System.out.println("*** ERROR - malformed PPG URL"); } catch (IOException exception) { System.out.println( "*** ERROR - I/O exception"); } catch (Exception exception) { System.out.println("*** ERROR - exception(" + exception.getMessage() + ")"); } }//main() }//class ServiceInd |
| [] [返回上一页] [打 印] |
|
文章评论 |
