Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#SOAP客户端增加了大量时间_C#_Soap - Fatal编程技术网

C#SOAP客户端增加了大量时间

C#SOAP客户端增加了大量时间,c#,soap,C#,Soap,我正在尝试调用NetSuite API的实例。这需要生成nonce和时间戳以及使用者和令牌密钥。当完成所有这些并从邮递员那里发送请求时,大约需要6秒钟。生成基本C#项目、将SOAP端点添加为“连接的服务”并调用它时,需要20秒。为什么通过C#发送请求要花这么长时间 var-credentials=新的令牌凭据(accountId、consumerKey、consumerSecret、tokenId、tokenSecret); var client=new ServiceReference1.Ne

我正在尝试调用NetSuite API的实例。这需要生成nonce和时间戳以及使用者和令牌密钥。当完成所有这些并从邮递员那里发送请求时,大约需要6秒钟。生成基本C#项目、将SOAP端点添加为“连接的服务”并调用它时,需要20秒。为什么通过C#发送请求要花这么长时间

var-credentials=新的令牌凭据(accountId、consumerKey、consumerSecret、tokenId、tokenSecret);
var client=new ServiceReference1.NetSuitePortTypeClient();
client.Endpoint.Address=新端点地址(新Uri(),client.Endpoint.Address.Identity,client.Endpoint.Address.Headers.ToArray());
var passport=credentials.GeneratePassport();
var sw=Stopwatch.StartNew();
var something=await client.getAsync(null,passport,null,null,null,new RecordRef{type=RecordType.customer,typeSpecified=true,internalId=“2116”});
sw.Stop();
var ms=sw.ElapsedMilliseconds;

您是否尝试将
async
await
一起使用,而不是使用
Result
属性?@BiesiGrr提示此问题的代码已在其中等待。这里我使用
.Result
,因为它位于同步上下文中,所以我不能等待它。
var credentials = new TokenCredentials(accountId, consumerKey, consumerSecret, tokenId, tokenSecret);
var client = new ServiceReference1.NetSuitePortTypeClient();
client.Endpoint.Address = new EndpointAddress(new Uri(<url>), client.Endpoint.Address.Identity, client.Endpoint.Address.Headers.ToArray());
var passport = credentials.GeneratePassport();
var sw = Stopwatch.StartNew();
var something = await client.getAsync(null, passport, null, null, null, new RecordRef {type = RecordType.customer, typeSpecified = true, internalId = "2116"});
sw.Stop();
var ms = sw.ElapsedMilliseconds;