在黑莓中使用 ksoap 开发应用程序

发布于 2024-12-26 03:09:00 字数 3308 浏览 3 评论 0原文

我是黑莓开发的新手。我的任务是使用 Web 服务开发应用程序来查找位置并将数据发送到服务器。

我已经为肥皂请求开发了以下代码,但是当我将其运行到我的手机时,什么也没有发生。甚至数据也没有发送到服务器。请帮助我并提供一些有关此源代码的指南。

final class MyScreen extends SplashScreen  {

    private String serviceUrl = "myurl/GPStracker.asmx";
    private String serviceNamespace = "http://tempuri.org/";
    private String soapAction = "http://tempuri.org/GPSUnikeylogin";
    private String methodName = "GPSUnikeylogin";

    private String imei = GPRSInfo.imeiToString(GPRSInfo.getIMEI(), false);

    private BasicEditField roundedBorderEdit = null;
    private ButtonField bf;
    private String responseBody;
    Hashtable persistentHashtable; 
    PersistentObject persistentObject;
    static final long KEY = 0x9df9f961bc6d6baL;

    public MyScreen(Bitmap popup, int seconds) {
            super(Bitmap.getBitmapResource("bg.png"), 5);

                //persistentObject = PersistentStore.getPersistentObject(KEY);
                 roundedBorderEdit = new BasicEditField();
                 roundedBorderEdit = new BasicEditField("","",50,EditField.EDITABLE | EditField.FILTER_NUMERIC | EditField.FIELD_HCENTER) {
                     public void paint(Graphics g) {
                         super.paint(g);
                         g.drawRect(0, 0, getWidth(), getHeight());
                     }
                 };
                 add(roundedBorderEdit);

                 bf = new ButtonField ("Register", Field.FOCUSABLE);
                 bf.setChangeListener(new FieldChangeListener(){
                     public void fieldChanged(Field field, int context) {

                         callWebService();

                     }
                 });
                 add (bf);

    }   
    private void callWebService()
    {
        String e =  "123";//MyScreen.this.roundedBorderEdit.getText();
        //Dialog.alert(e.toString());

        SoapObject rpc = new SoapObject(serviceNamespace, methodName);
        //Dialog.alert(rpc.toString());

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

        rpc.addProperty("vUnikey",e.toString());
        rpc.addProperty("vImei_No",imei.toString());

        //Dialog.alert(rpc.toString());
        envelope.setOutputSoapObject(rpc);
        envelope.bodyOut = rpc;
        envelope.dotNet = true;
        envelope.encodingStyle = SoapSerializationEnvelope.XSI;

        HttpTransport ht = new HttpTransport(serviceUrl);//+ ";deviceside=true;apn=blackberry.net");

        Dialog.alert(ht.toString());

        //HttpTransport ht = new HttpTransport(serviceUrl);
        ht.debug = true;
        ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        //Dialog.alert("set to xml");
        String result= null;

        try{

            ht.call(soapAction, envelope);
            Dialog.alert(ht.toString());
            result = (envelope.toString());
            Dialog.alert(result.toString());
        }

        catch (org.xmlpull.v1.XmlPullParserException ex2) {
        }

        catch (Exception ex) {
             String bah = ex.toString();
             System.out.println(bah);
        }
    }
} 

在上面的代码中,我接到电话直到 ht.call(soapAction, 信封);之后我没有收到服务器的任何响应。而且我也没有获得正确的方法来授予互联网访问权限和设备的其他访问权限。

因此,请帮助我并为我提供一些借助肥皂信封上传数据的步骤。

i am new in blackberry development. and i have task to develop the application using web service to find the location and send the data to the server.

I have developed the following code for the soap request but when i run it to my mobile nothing is happening. and even data is also not sending to the server. Please help me and provide some guide to for this source code.

final class MyScreen extends SplashScreen  {

    private String serviceUrl = "myurl/GPStracker.asmx";
    private String serviceNamespace = "http://tempuri.org/";
    private String soapAction = "http://tempuri.org/GPSUnikeylogin";
    private String methodName = "GPSUnikeylogin";

    private String imei = GPRSInfo.imeiToString(GPRSInfo.getIMEI(), false);

    private BasicEditField roundedBorderEdit = null;
    private ButtonField bf;
    private String responseBody;
    Hashtable persistentHashtable; 
    PersistentObject persistentObject;
    static final long KEY = 0x9df9f961bc6d6baL;

    public MyScreen(Bitmap popup, int seconds) {
            super(Bitmap.getBitmapResource("bg.png"), 5);

                //persistentObject = PersistentStore.getPersistentObject(KEY);
                 roundedBorderEdit = new BasicEditField();
                 roundedBorderEdit = new BasicEditField("","",50,EditField.EDITABLE | EditField.FILTER_NUMERIC | EditField.FIELD_HCENTER) {
                     public void paint(Graphics g) {
                         super.paint(g);
                         g.drawRect(0, 0, getWidth(), getHeight());
                     }
                 };
                 add(roundedBorderEdit);

                 bf = new ButtonField ("Register", Field.FOCUSABLE);
                 bf.setChangeListener(new FieldChangeListener(){
                     public void fieldChanged(Field field, int context) {

                         callWebService();

                     }
                 });
                 add (bf);

    }   
    private void callWebService()
    {
        String e =  "123";//MyScreen.this.roundedBorderEdit.getText();
        //Dialog.alert(e.toString());

        SoapObject rpc = new SoapObject(serviceNamespace, methodName);
        //Dialog.alert(rpc.toString());

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

        rpc.addProperty("vUnikey",e.toString());
        rpc.addProperty("vImei_No",imei.toString());

        //Dialog.alert(rpc.toString());
        envelope.setOutputSoapObject(rpc);
        envelope.bodyOut = rpc;
        envelope.dotNet = true;
        envelope.encodingStyle = SoapSerializationEnvelope.XSI;

        HttpTransport ht = new HttpTransport(serviceUrl);//+ ";deviceside=true;apn=blackberry.net");

        Dialog.alert(ht.toString());

        //HttpTransport ht = new HttpTransport(serviceUrl);
        ht.debug = true;
        ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        //Dialog.alert("set to xml");
        String result= null;

        try{

            ht.call(soapAction, envelope);
            Dialog.alert(ht.toString());
            result = (envelope.toString());
            Dialog.alert(result.toString());
        }

        catch (org.xmlpull.v1.XmlPullParserException ex2) {
        }

        catch (Exception ex) {
             String bah = ex.toString();
             System.out.println(bah);
        }
    }
} 

In the above code i am getting the call till ht.call(soapAction, envelope); after that i am not getting any response from the server. and i also not get the proper way to give the permission for the internet access and other access from the device.

So please help me and provide me some step to upload data with the help of soap envelope.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌逼全场 2025-01-02 03:09:00

您可能想查看 ksoap2-android 项目。它的代码仍然兼容 Java 1.3/Java ME,并且应该可以在黑莓设备上正常工作。

You might want to look at the ksoap2-android project. Its code is still Java 1.3/Java ME compatible and should work just fine on blackberry devices..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文