顯示具有 Web Service 標籤的文章。 顯示所有文章
顯示具有 Web Service 標籤的文章。 顯示所有文章

2019年5月8日 星期三

Invoke關卡呼叫.Net web service(asmx)

1-1.web service網站的web.config需新增HttpPost protocol













1-2.在asmx.cs的開頭
將[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
改成[WebServiceBinding(ConformsTo = WsiProfiles.None)]








1-3.在method開頭新增
[SoapRpcMethod(Use = System.Web.Services.Description.SoapBindingUse.Literal)]






注意:1-2跟1-3都要設定,不然會有參數值為null的問題;
另外method只支援string型態的參數跟回傳結果
1)如果參數其中之一不是string型態,則無法進入method(找不到method)
2)如果回傳結果不是string型態,則無法回傳結果






2.Invoke關卡選擇web service



3.選擇HttpPost















4.再設定參數對應的流程變數即可。


2018年11月6日 星期二

jQuery soap插件(jQuery呼叫.Net web service用)的使用方法

**IE瀏覽器**
網際網路選項→安全性→所對應的區域→自訂等級→存取跨網域的資料來源→啟用



引用如下:
<!--IE8只能用jQuery 1.x版本-->
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
<script src="http://cdn.zoanmgtinc.com/j_query/plugin/soap/jquery.soap.js"></script>



方法如下:
 $.support.cors = true; /**修正"no transport"問題(for IE8, http://bugs.jquery.com/ticket/10660)*/
$.soap({
url: "http://xxx.xxx.xxx.xxx/WebSite1_T/Service.asmx",
method: "<方法名稱>",
SOAPAction: "http://tempuri.org/<方法名稱>",
envAttributes: {
"xmlns": "http://tempuri.org/"
},
data: {
Code: "", /**參數1*/
Display: true /**參數2*/
},
appendMethodToURL: false,
async: false,
success: function (soapResponse) {
/**成功時解析soapResponse的內容*/
/**建議用$(soapResponse.toString())轉成jQuery的xml物件以利操作*/
},
error: function (soapResponse) {
/**失敗時soapResponse會顯示伺服器回傳錯誤訊息*/
}
});



在web service伺服器的web.config的<configuration>節點底下加上
 <system.webServer> 
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="content-type, soapaction" />
<add name="Access-Control-Allow-Methods" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>

2018年7月13日 星期五

Excel叫用Web service

1.VBA編輯器→工具→設定引用項目


2.增加Microsoft Office Soap Type Library v3.0
(路徑:C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\MSSOAP30.DLL)

Microsoft XML, v6.0


3.以下代碼叫用即可 
 Dim service As SoapClient30 

Dim result As MSXML2.IXMLDOMSelection '回傳結果
Dim isOk As MSXML2.IXMLDOMElement '回傳結果屬性(執行結果OK/NG)
Dim message As MSXML2.IXMLDOMElement '回傳結果屬性(返回訊息)
Dim value As MSXML2.IXMLDOMElement '回傳結果屬性(返回值)


Set service = New SoapClient30
Call service.MSSoapInit("WSDL的URL")

Set result = service.方法名稱("參數")
Set isOk = result.Item(0)
Set message = result.Item(1)
Set value = result.Item(2)

2017年11月22日 星期三

SSRS無法解析ASP.NET Web Service回傳結果

場景:
1_使用ASP.NET建立Web Service,回傳結果格式為DataSet。















2_欲使用SSRS將回傳結果當成Data Source以利重用,卻發現結果不是我們要的。










3_建立自訂類別取代DataSet如下,將屬性為基本類型並設為公開:











4_SSRS可正確解析。