Home > Mobile >  Android using ksoap2 jar packages, the server is not received parameter is null, the null pointer, c
Android using ksoap2 jar packages, the server is not received parameter is null, the null pointer, c

Time:10-22

 public class ConnectSQL {
/* *
A return value. * @ the return of the WebService
*/
Private static String WEB_SERVICE_URL="HTTP://http://*. * : 80/Service1. Asmx? Op=";//test

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

String ExceptionResult=null;

Public String CallWebService (String MethodName, Map Params) {
Try {
//1, specifies the namespace and invoke methods webservice
SoapObject request=new SoapObject (Namespace, MethodName);
//2, set the parameter values of calls the method, if there are no parameters, can be omitted,
If (Params!=null) {
@ SuppressWarnings (" rawtypes ")
The Iterator iter=Params. EntrySet (). The Iterator ();
While (iter. HasNext () & amp; & Iter!=null) {
@ SuppressWarnings (" rawtypes ")
Map.Entry entry=(Map.Entry) iter.next();
//set to invoke the web service interface to the incoming parameter
//the original written
//request. AddProperty ((String) entry. GetKey (), (String) entry. The getValue ());
//soapObject. AddProperty (key, params. Get (key));
////revised writing (must need to invoke the web service interface to set parameters)
PropertyInfo PI=new PropertyInfo ();
PI. SetNamespace (Namespace);
PI. Elegantly-named setName ((String) entry. GetKey ());
PI. SetValue ((String) entry. The getValue ());
PI. SetType (entry. GetValue () getClass ());
Request. AddProperty (PI);
}
}
//3, the Webservice calling SOAP request information, this information by SoapSerializationEnvelope object description
//create SoapSerializationEnvelope object and specify the soap version
SoapSerializationEnvelope envelope=new SoapSerializationEnvelope (SoapEnvelope. VER12);
//because it is sending a request, so is to set up bodyOut
Envelope. BodyOut=request;
//c # to write the application must be combined with it, is. Net development webservice, so this should be set to true
Envelope. DotNet=true;
HttpTransportSE ht=new HttpTransportSE (WEB_SERVICE_URL, 20000);
Try {
//call method is used to invoke the web service method
Ht. The call (null, envelope);
} the catch (HttpResponseException e) {
ExceptionResult="anomalies information is as follows:" + e. oString ();
} the catch (IOException e) {
ExceptionResult="anomalies information is as follows:" + e. oString ();
} the catch (XmlPullParserException e) {
ExceptionResult="anomalies information is as follows:" + e. oString ();
}
//get the data returned
SoapObject object=(SoapObject) envelope. BodyIn;
//get the result returned
The String result=object. GetProperty (0). The toString ();
If (result!=null) {
return result;
}
} the catch (Exception e) {
Return anomalies information is as follows: "unknown error" + e. oString ();
}
Return ExceptionResult;
}
}



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

The namespace LinkedMesService
{

[WebService (Namespace="http://tempuri.org/")]
[WebServiceBinding (ConformsTo=WsiProfiles. BasicProfile1_1)]
[System.Com ponentModel 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 and 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)
{
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related