J2me Web服务调用和错误java.rmi.ServerException:

发布于 2024-10-07 23:42:41 字数 1812 浏览 0 评论 0原文

您好,我正在创建一个 J2ME 应用程序,我需要在其中调用 Web 服务进行处理 我正在加密数据,然后调用 Web 服务

我的代码在我的 Linux(Fedora)上运行完美,但在我的 Windows 和实际移动设备上运行不正常 服务器正在使用 JBoss 和 EJB

代码:-

CryptoEngine.setEncryptionKey("ROFTALPTNEMYAP1A");                      

String IMEI = "IMEI="+txtIMEI.getString();
String phoneno = "phoneNumber="+txtPhoneNo.getString();

System.out.println(IMEI);
System.out.println(phoneno);

String en = CryptoEngine.encryptString(phoneno + ";" + IMEI);
System.out.println(en);
byte[] ben = en.getBytes();
System.out.println("En = " + en);
String BaseEn = new String (Base64.encode(ben));


System.out.println("Base64 En = " + BaseEn);
form.append(en);

/*
 * Code For webservice
 */
A1Stubs.A1MobileService_Stub stub = new A1Stubs.A1MobileService_Stub();
stub._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, "http://41.86.150.26:9090/A1Payment-A1Payment-ejb/A1MobileService");
String response = stub.getKey(BaseEn);
form.append("Reached After Web-service Called");
System.out.println(response);

/*
 * End  of Web Serivce
 */

byte[] baseDecode = Base64.decode(response);
String Decrypt = CryptoEngine.decryptString(new String(baseDecode));
System.out.println(Decrypt);
item.setText("Encrypted Text: \n"+en+"\n\n BASE64 Encryption: \n"+new String(Base64.encode(ben))+"\n\n Response of Web-Service : \n"+response+"\n\n BASE64 Decryption : \n"+new String(baseDecode)+"\n\n Decrypted Text : \n"+Decrypt);
display.setCurrent(form);

在 Windows 机器上,我在调用 Web 服务后收到以下错误

java.rmi.ServerException: 
[Code:   env:Server] 
[String: String index out of range: -1] 
        at com.sun.j2mews.xml.rpc.OperationImpl.setupResStream(OperationImpl.java:380)
        at com.sun.j2mews.xml.rpc.OperationImpl.invoke(OperationImpl.java:236)

,为什么我遇到这个问题???

Hello i am creating a J2ME application in which i need to call a web service for processing
i am encrypting data and then calling web service

my code is working perfect on my Linux(Fedora) but not working on my windows and actual mobile
Server is using JBoss and EJB

Code :-

CryptoEngine.setEncryptionKey("ROFTALPTNEMYAP1A");                      

String IMEI = "IMEI="+txtIMEI.getString();
String phoneno = "phoneNumber="+txtPhoneNo.getString();

System.out.println(IMEI);
System.out.println(phoneno);

String en = CryptoEngine.encryptString(phoneno + ";" + IMEI);
System.out.println(en);
byte[] ben = en.getBytes();
System.out.println("En = " + en);
String BaseEn = new String (Base64.encode(ben));


System.out.println("Base64 En = " + BaseEn);
form.append(en);

/*
 * Code For webservice
 */
A1Stubs.A1MobileService_Stub stub = new A1Stubs.A1MobileService_Stub();
stub._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, "http://41.86.150.26:9090/A1Payment-A1Payment-ejb/A1MobileService");
String response = stub.getKey(BaseEn);
form.append("Reached After Web-service Called");
System.out.println(response);

/*
 * End  of Web Serivce
 */

byte[] baseDecode = Base64.decode(response);
String Decrypt = CryptoEngine.decryptString(new String(baseDecode));
System.out.println(Decrypt);
item.setText("Encrypted Text: \n"+en+"\n\n BASE64 Encryption: \n"+new String(Base64.encode(ben))+"\n\n Response of Web-Service : \n"+response+"\n\n BASE64 Decryption : \n"+new String(baseDecode)+"\n\n Decrypted Text : \n"+Decrypt);
display.setCurrent(form);

on windows machine i am getting following error after calling web service

java.rmi.ServerException: 
[Code:   env:Server] 
[String: String index out of range: -1] 
        at com.sun.j2mews.xml.rpc.OperationImpl.setupResStream(OperationImpl.java:380)
        at com.sun.j2mews.xml.rpc.OperationImpl.invoke(OperationImpl.java:236)

why i am facing this problem????

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

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

发布评论

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

评论(1

聽兲甴掵 2024-10-14 23:42:42

看来服务器端有问题。此类错误表明您收到的流中没有任何内容可供读取。您应该检查服务器日志以了解发生了什么。

Seems like there is a problem server-side. This type of error indicates that there is nothing to read in the stream you received. You should check the server logs to see what happened.

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