Web Services Soap Web服务返回空值

klh5stk1  于 2023-03-30  发布在  其他
关注(0)|答案(1)|浏览(196)

我想为我的项目使用一个Web服务,我确信Web服务工作正常(我在Boomerang - SOAP & REST客户端测试). Web service link.但当我尝试从服务获取数据时,服务返回null,空或0值。我认为VS添加Web服务引用不正确,但无法找到问题所在。

static async Task<String> GetProductAsyncN11()
    {

        ServicePointManager.Expect100Continue = true;
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
        var port = new N11ProductServiceReference.ProductServicePortClient();
        var requ = new GetProductListRequest();
        requ.auth = new N11ProductServiceReference.Authentication();         
        requ.auth.appKey = "*****";
        requ.auth.appSecret = "*****";
        requ.pagingData = new N11ProductServiceReference.RequestPagingData();
        requ.pagingData.pageSize = 100;
        requ.pagingData.currentPage = 0;
        var list =await port.GetProductListAsync(requ);
        Console.WriteLine(list.GetProductListResponse.products.Rank);
        Console.WriteLine("xx" + list.GetProductListResponse.result.status);
        Console.WriteLine("xx" + list.GetProductListResponse.products.Length);
        foreach (var item in list.GetProductListResponse.products)
        {
            Console.WriteLine(item.productSellerCode+item.price+item.saleStatus);
        }
        return "n11";
    }

响应在这里

另外,当我使用Boomerang - SOAP & REST客户端时,以下是响应

7gcisfzg

7gcisfzg1#

幸运的是,我解决了这个问题。当我添加服务引用时,Visual Studio改变了顺序。我重新排列了顺序,问题解决了。
这是真实的订单(取自Boomerang-SOAP & REST客户端);

<currencyAmount>51.00</currencyAmount>
                <currencyType>1</currencyType>
                <displayPrice>45.90</displayPrice>
                <isDomestic>false</isDomestic>
                <id>457916487</id>
                <price>51.00</price>
                <productSellerCode>BZRG</productSellerCode>
                <approvalStatus>2</approvalStatus>
                <saleStatus>3</saleStatus>
                <stockItems>
                    <stockItem>
                        <bundle>true</bundle>
                        <currencyAmount>51.00</currencyAmount>
                        <displayPrice>45.90</displayPrice>
                        <optionPrice>51.00</optionPrice>
                        <sellerStockCode>BZRG01BJ</sellerStockCode>
                        <attributes>
                            <attribute>
                                <name>ADET</name>
                                <value>1</value>
                            </attribute>
                            <attribute>
                                <name>RENK</name>
                                <value>BEJ</value>
                            </attribute>
                        </attributes>
                        <id>126921525657</id>
                        <quantity>0</quantity>
                        <version>3</version>
                    </stockItem>
                  ...
                </stockItems>
                <subtitle>Bazerga Lüks Kapı Altı Soğuk Toz Böcek Önleyici</subtitle>
                <title>Bazerga Dekoratif Kapı Altı Rüzgar Önleyici 90 cm Renk Çeşitleri</title>
                <unitInfo/>

这是Visual Studio创建的命令

private long idField;
    
    private string productSellerCodeField;
    
    private string titleField;
    
    private string subtitleField;
    
    private decimal priceField;
    
    private decimal displayPriceField;
    
    private bool isDomesticField;
    
    private string saleStatusField;
    
    private string approvalStatusField;
    
    private ProductSkuList stockItemsField;
    
    private decimal oldPriceField;
    
    private decimal currencyAmountField;
    
    private string currencyTypeField;

我更改了此部分的订单编号

[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=4)]

相关问题