android 使用ksoap2 jar包时,服务器端没有接收到参数为null,报空指针,能帮忙看下什么问题吗?

sophialise 2019-06-26 02:08:24
public class ConnectSQL {
/**
* @return WebService的返回.值
*/
private static String WEB_SERVICE_URL = "http://*.*:80/Service1.asmx?op=";//测试

private static String Namespace = "http://tempuri.org/";

String ExceptionResult = null;

public String CallWebService(String MethodName, Map<String, String> Params) {
try {
// 1、指定webservice的命名空间和调用的方法名
SoapObject request = new SoapObject(Namespace, MethodName);
// 2、设置调用方法的参数值,如果没有参数,可以省略,
if (Params != null) {
@SuppressWarnings("rawtypes")
Iterator iter = Params.entrySet().iterator();
while (iter.hasNext() && iter != null) {
@SuppressWarnings("rawtypes")
Map.Entry entry = (Map.Entry) iter.next();
// 设置需调用WebService接口需要传入的参数
// 原来写法
// request.addProperty((String) entry.getKey(), (String) entry.getValue());
// soapObject.addProperty(key, params.get(key));
// //  修改后的写法(设置需调用WebService接口需要传入的参数)
PropertyInfo pi = new PropertyInfo();
pi.setNamespace(Namespace);
pi.setName((String) entry.getKey());
pi.setValue((String) entry.getValue());
pi.setType(entry.getValue().getClass());
request.addProperty(pi);
}
}
// 3、生成调用Webservice方法的SOAP请求信息。该信息由SoapSerializationEnvelope对象描述
// 创建SoapSerializationEnvelope 对象,同时指定soap版本号
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
// 由于是发送请求,所以是设置bodyOut
envelope.bodyOut = request;
// c#写的应用程序必须加上这句,是.net开发的webservice,所以这里要设置为true
envelope.dotNet = true;
HttpTransportSE ht = new HttpTransportSE(WEB_SERVICE_URL, 20000);
try {
// 使用call方法调用WebService方法
ht.call(null, envelope);
} catch (HttpResponseException e) {
ExceptionResult = "发生异常信息如下:" + e.toString() ;
} catch (IOException e) {
ExceptionResult = "发生异常信息如下:" + e.toString() ;
} catch (XmlPullParserException e) {
ExceptionResult = "发生异常信息如下:" + e.toString() ;
}
// 获取返回的数据
SoapObject object = (SoapObject) envelope.bodyIn;
// 获取返回的结果
String result = object.getProperty(0).toString();
if (result != null) {
return result;
}
} catch (Exception e) {
return "发生异常信息如下:未知错误" + e.toString() ;
}
return ExceptionResult;
}
}



C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using LinkedMesService.Linked;
using System.Drawing.Printing;
using System.Drawing;

namespace LinkedMesService
{

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
public string getResult(string sql)
{
return LoadResult.loadData(sql);
}

public string insertData(string sql)
{
return LoadResult.insertData(sql);
}

public int insertProc(string tableName,string fields,string values)
{
return LoadResult.insertProc(tableName,fields, values);
}

public String selectMBRowData(string WorkOrderNo,string CreatePS,string ActionName, string Shift,string machineNo, string lotNo)
{
return LoadResult.selectMBRowData(WorkOrderNo, CreatePS, ActionName, Shift,machineNo, lotNo);
}

public String initButtonStatus(string machineNo, string procName)
{
return LoadResult.initButtonStatus(machineNo, procName);
}


public String getWaferInfo(string selectCondition)
{
return LoadResult.getWaferInfo(selectCondition);
}


public String getRowNum(string WorkOrderNo)
{
return LoadResult.getRowNum(WorkOrderNo);
}


public String UpdatePutInQty(string WorkOrderNo, string BatchNo)
{
return LoadResult.UpdatePutInQty(WorkOrderNo, BatchNo);
}


public String productVsMaterial(string WorkOrderNo, string CreatePS, string ActionName, string ActionDesc,
string MachineNo, string NowAntennaBatchNo, string NowWaferBatchNo, string NowACPBatchNo,string nowMinAcpNo,string procName)
{
return LoadResult.productVsMaterial(WorkOrderNo, CreatePS, ActionName, ActionDesc, MachineNo,
NowAntennaBatchNo, NowWaferBatchNo, NowACPBatchNo,nowMinAcpNo, procName);
}


public String getBigBatchNo(string MachineNo, int GoodOrBad, string procName)
{
return LoadResult.getBigBatchNo(MachineNo, GoodOrBad, procName);
}


public String LoadingBatchNo(string BatchNoString,string PrevBatchNoString,string WorkOrderNo, string CreatePS, string MachineNo, string ActionName,int RelationNo, string procName)
{
return LoadResult.LoadingBatchNo(BatchNoString, PrevBatchNoString, WorkOrderNo, CreatePS, MachineNo, ActionName, RelationNo,procName);
}

public String getMaterialNoDifference(string machineNo, string materialNo, string workOrderNo, string Operator, string actionName, string procName)
{
return LoadResult.getMaterialNoDifference(machineNo, materialNo, workOrderNo, Operator, actionName, procName);
}

public String getRelationNo(string machineNo, string workOrderNo, string Operator,string actionName,string procName)
{
return LoadResult.getRelationNo(machineNo, workOrderNo, Operator,actionName, procName);
}

public String getMaterialReport(string MBatchNo, string WorkOrderNo,string ActionName,string MachineNo, string procName)
{
return LoadResult.getMaterialReport(MBatchNo, WorkOrderNo, ActionName,MachineNo, procName);
}

public String getOrderStuationReport(string WorkOrderNo, string Shift, string MachineNo,string procName)
{
return LoadResult.getOrderStuationReport(WorkOrderNo, Shift,MachineNo, procName);
}

}
}


这是报错信息

几个方法同时连接数据库,有的方法执行成功 ,有的方法就会提示如下图的报错信息,有时调用一个方法也不成功,数据不能插入数据库,有时方法会被多次执行,数据库生成重复数据,实在没调出来什么哪个地方有问题,但是换个网络,这种问题发生频率会小很多,还有就是提示这样的错之后,关机重启就ok了,能帮忙看下什么问题吗?
...全文
66 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

80,471

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧