我正在尝试使用API从另一台服务器访问数据,但出现错误。
web.config客户端标记:
<endpoint address="http://api.domain.co.za/FTIntegration.svc/BalanceLookup" binding="basicHttpBinding" bindingConfiguration="MembershipSoap" contract="FTFeverTreeWebService.IFTIntegration" name="MembershipSoap" />
web.config绑定标记:
<basicHttpBinding>
<binding name="GlobalWeatherSoap" />
<binding name="MembershipSoap" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2000000" maxBufferPoolSize="524288" maxReceivedMessageSize="2000000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="4000000" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
错误来自以下代码行:
FTFeverTreeWebService.Result_BalanceLookup blR = ft.BalanceLookup(bl);
我的整个代码:
FeverTreeResponse response = new FeverTreeResponse();
try
{
FTFeverTreeWebService.BalanceLookup bl = new FTFeverTreeWebService.BalanceLookup { BalanceID = request.BalanceID, CardOrIDNumber = request.CardOrIDNumber };
FTFeverTreeWebService.FTIntegrationClient ft = new FTFeverTreeWebService.FTIntegrationClient();
FTFeverTreeWebService.Result_BalanceLookup blR = ft.BalanceLookup(bl);
response.Facility = blR.Facility;
response.Name = blR.Name;
response.Available = blR.Available;
response.Success = blR.Success;
response.Message = blR.Message;
response.CardOrIDNumber = blR.CardOrIDNumber;
response.InternalReference = blR.InternalReference;
}
catch (ValidationException e)
{
response.Success = false;
response.Message = e.ValidationResult.ErrorMessage;
//response.DebugMessage = e.StackTrace;
}
return response;