4

I am attempting to perform some basic integration using Acumatica's web services. Unfortunatly, I'm having problems logging in. According to their documentation, this process should look something like:

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");

Simple enough. However, after creating and importing a WSDL file from Acumatica into Visual Studio, I found I don't have a Screen object. I do, however have a ScreenSoapClient object, which has a similar Login() method.

ScreenSoapClient context = new Acumatica.ScreenSoapClient("ScreenSoap");
LoginResult result = context.Login("username", "password");

That part works. In fact, the LoginResult give me a session ID. However, if I try to make any calls to the service, such as:

CR401000Content cr401000 = context.CR401000GetSchema();

I get an error: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> PX.Data.PXNotLoggedInException: Error #185: You are not currently logged in.

While the version of Acumatica we're using does appear to be slightly newer, I'm unsure why the Screen() object isn't available. Consequently, if I try a bad username/password, Login() does fail (as it should). From what I can the tell, the ScreenSoapClient class is using service model details from web.config, so it's getting the endpoint address and other details there.

Is there something I'm missing or doing wrong?

4

2 回答 2

3

如我所见,您使用 WCF 创建服务引用。所以你应该在服务绑定中启用cookies:

var binding = new BasicHttpBinding()
{
    AllowCookies = true
};

var address = new EndpointAddress("http://localhost/WebAPIVirtual/Soap/APITEST.asmx");

var c = new ServiceReference1.ScreenSoapClient(binding, address);

或者,您可以使用旧的 asmx Web 服务参考 ( http://msdn.microsoft.com/en-us/library/bb628649.aspx )。然后一切都将与 Acumatica 的文档中的相同。

于 2014-09-17T07:56:33.700 回答
0

如上面评论中所述,我能够与 Acumatica 的代表取得联系。他让我删除然后在我们的项目中重新创建服务引用并重试。这显然起到了作用,“错误#185:您当前未登录”错误消失了。

于 2014-10-14T13:45:41.093 回答