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了,能幫忙看下什么問題嗎?
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/132651.html
標籤:Android
上一篇:求助這是為什么?
