c# - Experian QAS SOAP 请求 c#

标签 c# web-services soap

我需要使用 SOAP 向 Experian 服务发出请求。

文档令人震惊,给出的示例代码更糟糕。所以我希望有人能提供帮助。

首先,我只想从测试调用中获得响应,使用 https://ws.ondemand.qas.com/ProOnDemand/V3/ProOnDemandService.asmx?op=DoGetExampleAddresses在那之后,我很确定我能解决问题。

有人能帮忙吗?

        ///Service Reference
        Experian.QAS.QAAuthentication authentication = new Experian.QAS.QAAuthentication();
        authentication.Username = "username";
        authentication.Password = "password";

        Experian.QAS.QAQueryHeader header = new Experian.QAS.QAQueryHeader();
        header.QAAuthentication = authentication;

        Experian.QAS.QAGetExampleAddresses body = new Experian.QAS.QAGetExampleAddresses();
        body.Country = "GBR";
        body.Layout = "QADefault";

        //I think this is the wrong call to post the request
        Experian.QAS.DoGetExampleAddressesRequest request = new Experian.QAS.DoGetExampleAddressesRequest(header, body);

最佳答案

代码最后一行的注释是正确的,那是操作的 SOAP 请求对象,而不是操作本身。

在示例代码的某处是否有继承自 SoapHttpClientProtocol 的类(例如称为 QASOnDemandIntermediary)?

您需要实例化该类的一个实例,将您的身份验证对象分配给它,然后在执行您需要执行的操作的客户端上调用该方法,例如:

// Create authentication object
QAAuthentication authentication = new QAAuthentication();
authentication.Username = "MyUserName";
authentication.Password = "MyPassword";

// Create SOAP header and assign authentication parameters to it
QAQueryHeader header = new QAQueryHeader();
header.QAAuthentication = authentication;

// Create service client
QASOnDemandIntermediary client = new QASOnDemandIntermediary();
client.QAQueryHeaderValue = header;

// Create service request
QAGetExampleAddresses request = new QAGetExampleAddresses();
request.Country = "GBR";
request.Layout = "QADefault";

// Call the web service
QAExampleAddress[] result = client.DoGetExampleAddresses(request);

// Use the result
foreach (var example in result)
{
    // Use the examples
}

我无法访问您正在使用的确切示例代码,因此我使用的一些类型名称可能不是 100% 正确,但它们应该是相似的。

关于c# - Experian QAS SOAP 请求 c#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31140480/

相关文章:

c# - 在 SOAP 请求中添加 KeyInfo 引用

c# - 没有证书存储的 WCF 证书

c# - 将 DataGridView 与 C# 和 MySQL 一起使用

android - Appcelerator Titanium 中的 SOAP 问题(使用 suds.js)- 不适用于 Android

java - 在 Spring Boot 应用程序中调用 HTTPS SOAP Web 服务

JAVA hibernate/webservice - 时间戳问题

spring - 创建自己的 xml 命名空间

c# - 如何在 asp.net 母版页中将页脚保持在底部?

c# - String.Remove() 如何操作内存?

php - 根据URL参数生成SQL查询