我正在嘗試使用Acumatica的Web服務進行一些基本的集成。不幸的是,我遇到登錄問題。根據他們的文檔,這個過程應該看起來像這樣:Acumatica Web Services API登錄
apitest.Screen context = new apitest.Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.AllowAutoRedirect = true;
context.EnableDecompression = true;
context.Timeout = 1000000;
context.Url = "http://localhost/WebAPIVirtual/Soap/APITEST.asmx";
LoginResult result = context.Login("admin", "E618");
夠簡單。但是,在從Acumatica創建並導入到Visual Studio中的WSDL文件後,我發現我沒有Screen對象。不過,我有,但有一個ScreenSoapClient對象,它有一個類似的Login()方法。
ScreenSoapClient context = new Acumatica.ScreenSoapClient("ScreenSoap");
LoginResult result = context.Login("username", "password");
該部分起作用。實際上,LoginResult給我一個會話ID。但是,如果我努力使該服務的任何調用,如:
CR401000Content cr401000 = context.CR401000GetSchema();
我得到一個錯誤:System.Web.Services.Protocols.SoapException:服務器無法處理請求。 ---> PX.Data.PXNotLoggedInException:錯誤#185:您當前未登錄。
儘管我們使用的Acumatica版本看起來稍微更新,但我不確定爲什麼屏幕)對象不可用。因此,如果我嘗試使用錯誤的用戶名/密碼,Login()確實失敗(因爲它應該)。據我所知,ScreenSoapClient類正在使用web.config中的服務模型詳細信息,因此它獲得了端點地址和其他詳細信息。
有什麼我失蹤或做錯了嗎?
謝謝,安德魯。在和Acumatica的人一起工作後,我們發現刪除然後在我們的項目中重新創建服務引用修復了這些問題。不完全確定爲什麼,但它做到了! – rheldt 2014-10-14 13:33:30
允許cookies爲我工作。 – Anth12 2016-07-14 10:11:06