我是网络服务的新手,wsdl
我正在开发 abbyy flexicapture 网络服务,以在 fxicapture 中上传文件并在 xml 中获取数据。现在主要问题出现了,当我的代码处于调试模式(即在本地机器上)时,我将获取数据,但是当我将代码发布到远程服务器时,我会在 postAsync 方法编码数据时收到 403 错误。Abbyy flexicapture 分享了一个演示项目https://help.abbyy.com/en-us/flexicapture/12/developer/unattendedexample通过使用该代码我创建了一个 MVC 应用程序,在该应用程序中我成功地从服务器上使用窗口的 flexicapture 获取数据在我的本地机器上进行身份验证。
我正在与您分享我的错误,请查找
Error :-EXCEPTION OCCURRED:System.Net.Http.HttpRequestException Response status code does not indicate success: 403 (Forbidden). at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at WebServices.Controllers.HomeController.<FileRequest>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at WebServices.Controllers.HomeController.<UploadFile>d__17.MoveNext() System.Net.Http.HttpResponseMessage EnsureSuccessStatusCode()
Flexicapture 和 Webservice 在远程服务器上的同一个 IIS 上。
在此先感谢,请帮助我。
private static async Task<HttpResponseMessage> FileRequest(FlexicaptureWebservice.FlexiCaptureWebServiceSoapClient service, string action,int objectType, int sessionId, int projectId, int batchId, int parentId, int objectId, int version, string streamName)
{
var creds = CredentialCache.DefaultNetworkCredentials;
if (!string.IsNullOrEmpty(service.ClientCredentials.UserName.UserName))
creds = new NetworkCredential(service.ClientCredentials.UserName.UserName, service.ClientCredentials.UserName.Password);
using (var handler = new HttpClientHandler { Credentials = creds })
{
using (var client = new HttpClient(handler))
{
var uri = service.Endpoint.Address.Uri;
var content = new FormUrlEncodedContent(new Dictionary<string, string>
{
{"Action", action},
{"objectType", objectType.ToString()},
{"sessionId", sessionId.ToString()},
{"projectId", projectId.ToString()},
{"batchId", batchId.ToString()},
{"parentId", parentId.ToString()},
{"objectId", objectId.ToString()},
{"version", version.ToString()},
{"streamName", streamName},
});
var response = await client.PostAsync(uri.OriginalString.Replace("/API/v1/Soap","/FileService/v1").Trim(), content).ConfigureAwait(false);
response.EnsureSuccessStatusCode();
client.Dispose();
return response;
}
}
}