目的: V80201 - WebService 呼叫 & 顯示傳回資料說明 - AMM_PDM04
處理說明: 呼叫 WebService的步驟 1>將 WebService 的網址加入 專案 - 方案總管 --> 參考 --> 加入服務參考
Ex: http://enovia/AMM/Service.asmx Method: AMM_PDM04 2>完成後,
- 方案總管 --> Connect Service --> 多一 AMM_PDM04
3>web.config 移除重複 endpoint
- web.config --> 移除重複 endpoint of AMM_PDM04
4>呼叫 AMM_PDM04 函式
AMM_PDM04.ServiceSoapClient PDM04 = new AMM_PDM04.ServiceSoapClient();
DataSet ds = PDM04.AMM_PDM04("10-43-0301-001", "","AJT", "A", "0011",
"", "C", "2000/01/01","2022/12/05","",
"");
5>若無符合條件的資料,則顯示訊息
if (gridstore.data.getCount() == 0) {
mywarnalert("無符合條件的資料!!");
}
6>WebService 傳回 ds.tables , 修改成 T1 & T1C
1>Visual Studio 2019 IDE 操作畫面
1. 方案總管 à 參考 à 按右鍵 à 加入服務參考
Ex: http://enovia/AMM/Service.asmx
Method:
AMM_PDM04
2.於加入服務參考視窗設置參數如下圖
Ex: AMM_PDM01
3.確定後可至方案總管 à Connected Service查看

4.web.config à 將重複的endpoint 移除
--> 否則執行時,會出現 以致出現錯誤訊息(xx找到多個該合約的端點組態xx)
--> 將其中一個 AMM_PLM04 刪除即可
<endpoint address="http://enovia/AMM/Service.asmx"
binding="customBinding"
bindingConfiguration="ServiceSoap122"
contract="AMM_PDM01.ServiceSoap"
name="ServiceSoap12" />
4.呼叫webservice所提供之function
程式範例
ZRFC_ZM66.ZRFC_ZM66SoapClient sap = new ZRFC_ZM66.ZRFC_ZM66SoapClient();
DataSet ds = sap.CALL_Z_RFC_ZM66("1", MATNR, null, null, null, null, null, null, null, null, null, null, null, null, null);
DataTable dt = ds.Tables[0];
Sample2: *.cs
using
TLSWEB_AMM.AMM_PDM04;
AMM_PDM04.ServiceSoapClient PDM04 =
new AMM_PDM04.ServiceSoapClient();
DataSet ds =
PDM04.AMM_PDM04("10-43-0301-001", "","AJT",
"A", "0011",
"", "C", "2000/01/01","2022/12/05","",
"");
//將 WebService 取得的 ds , 改成 TMGrid的格式 T1 & T1C
DataTable dt = ds.Tables[0];
dt.TableName = "T1";
DataTable dt1 = ds.Tables.Add("T1C");
dt1.Columns.Add("TOTAL", typeof(Int32));
DataRow dr = ds.Tables["T1C"].NewRow();
dr["TOTAL"] = dt.Rows.Count;
ds.Tables["T1C"].Rows.Add(dr);
return ds;
實例: Web改版: V80201 - 呼叫WebService AMM_PDM04 {
xtype: 'button',
id: 'btn_Show',
flex: 2,
border: 1,
text: '資料顯示',
iconCls: 'icon-search',
handler: function () {
//檢核 [專案配置][生產工廠]不可均空白
var Tmp_PDM_CONFIG = Ext.getCmp('s_PDM_CONFIG').getValue();
var Tmp_FACWC = Ext.getCmp('s_FACWC').getValue();
var Tmp_Str = "";
if ((checkisnull(Tmp_PDM_CONFIG)) && (checkisnull(Tmp_FACWC))) {
Tmp_Str = "[專案配置][生產工廠]不可均空白, 敬請檢核";
mywarnalert(Tmp_Str);
return;
}
var np = s_JSON('s_form'); //TMFunction.js, 組合form上的查詢條件為json參數傳遞
np["s_STAT"] = Ext.getCmp('s_STAT').getValue();
console.log(" np[s_STAT] : ", np["s_STAT"]);
gridstore.getProxy().url = '../api/V80201API/getWebService_M';
gridstore.getProxy().extraParams = np; //分頁OK,篩選條件OK
gridstore.on("load", function () {
console.log("gridstore.onload !!");
if (gridstore.data.getCount() == 0) {
mywarnalert("無符合條件的資料!!");
}
});
gridstore.load();
} //end of 顯示資料.handler
}, // end of 顯示資料