WSDL 生成的服务引用返回 null

WSDL generated service reference returning null

我对外部源的服务引用有一些问题(在 Visual Studio 2015 年使用提供的 wsdl 添加它)。

情况是请求 i 运行 似乎可以正常到达服务器。我似乎也得到了预期 xml 格式的响应(添加了 TextWriterTraceListener)。但是我在代码中返回的 OutType class(在本例中为 GetBankCertificateOutType)始终为 null。

我为说明而构建的控制台应用程序非常简单,使用 public 测试帐户。它看起来如下:

static void Main(string[] args)
        {
            //instantiates client from the service reference
            var client = new PkiServicePortTypeClient();

            var time = DateTime.UtcNow;
            Random r = new Random();
            string reqId = r.Next(100, 999).ToString();

            var outType = client.GetBankCertificate(*full params on github*);

            //This line will throw nullexception since outType is always null
            //BUT a valid response is actually received (although returning aa application statusCode that represents error at this stage)
            var response = outType.GetBankCertificateResponse;
        }

我试图定位问题,但一直没有成功。所以想看看是否有人有一些关于如何调试这个的好技巧或者可能有解决方案。

我构建了一个完整的、最小的控制台示例项目(包括源 wsdl)来说明位于 here.

的问题

我已经下载并检查了您的解决方案,我在 trace.log

中找到了这个
GetBankCertificateRequest at tribute {http://www.w3.org/XML/1998/namespace}id  had invalid value '360817' of type '{http://www .w3.org/2001/XML Schema}ID'

在我使用 GetBankCertificateRequestid 值后,我得到了正确的值(而不是 null)。

var outType = client.GetBankCertificate(new GetBankCertificateInType {
            RequestHeader = new RequestHeaderType {
                SenderId = "360817",
                CustomerId = "360817",
                RequestId = reqId,
                Environment = EnvironmentType.test,
                EnvironmentSpecified = true,
                InterfaceVersion = "1",
                Timestamp = time
            },
            GetBankCertificateRequest = new GetBankCertificateRequest {
                BankRootCertificateSerialNo = "1111110002",
                //id = "",
                RequestId = reqId,
                Timestamp = time
            }
        });

根据文档 (PKI service description v2.3.pdf),除了一些 xml 类型注释 (xml:id) 外,没有对此 属性 的描述。缺少具体的模式描述。