简体   繁体   English

Asp.Net Core 连接服务 SOAP 方法始终 Null

[英]Asp.Net Core Connected Service SOAP Method Always Null

I'am using a SOAP service.我正在使用 SOAP 服务。 In the asp.net core project as connected service.在asp.net核心项目中作为连接服务。 Soap UI populated response. Soap UI 填充响应。 But not populated my method in the asp.net core.但没有在 asp.net 核心中填充我的方法。

I searched in many different places.我在许多不同的地方搜索过。 I checked everything.我检查了一切。 But I could not find a solution to the problem.但我找不到解决问题的办法。

var products = response.GetProductListResponse.products

An array is returned from the line above.从上面的行返回一个数组。 So far there is no problem.到目前为止没有问题。 Some features come full but most of them are blank I could not come up with a reasonable solution.有些功能很齐全,但大多数都是空白我想不出一个合理的解决方案。

You can find all the sample codes below.您可以在下面找到所有示例代码。 Thank you in advance for the help.预先感谢您的帮助。

model binding image! model绑定图片! response for .net View image回复 .net 查看图片

ConnectedService.Json ConnectedService.Json

  {
  "ProviderId": "Microsoft.VisualStudio.ConnectedService.Wcf",
  "Version": "15.0.40203.910",
  "ExtendedData": {
    "inputs": [
      "https://api.n11.com/ws/ProductService.wsdl"
    ],
    "collectionTypes": [
      "System.Collections.Generic.List`1",
      "System.Collections.Generic.Dictionary`2"
    ],
    "namespaceMappings": [
      "*, Soluto.Marketplace.WebServices.N11.Products"
    ],
    "targetFramework": "netcoreapp3.1",
    "typeReuseMode": "None"
  }
}

Request要求

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://www.n11.com/ws/schemas">
   <soapenv:Header/>
   <soapenv:Body>
      <sch:GetProductListRequest>
         <auth>
            <appKey>apikey</appKey>
            <appSecret>secretKey</appSecret>
         </auth>
         <pagingData>
            <currentPage>0</currentPage>
            <pageSize>200</pageSize>
         </pagingData>
      </sch:GetProductListRequest>
   </soapenv:Body>
</soapenv:Envelope>

Response回复

<env:Body>
      <ns3:GetProductListResponse xmlns:ns3="http://www.n11.com/ws/schemas">
         <result>
            <status>success</status>
         </result>
         <products>
            <product>
               <currencyAmount>223.00</currencyAmount>
               <currencyType>2</currencyType>
               <displayPrice>1766.16</displayPrice>
               <isDomestic>false</isDomestic>
               <id>453198848</id>
               <price>1766.16</price>
               <productSellerCode>123156d4sf56sd4f56s</productSellerCode>
               <approvalStatus>1</approvalStatus>
               <saleStatus>2</saleStatus>
               <stockItems>
                  <stockItem>
                     <bundle>false</bundle>
                     <currencyAmount>223.00</currencyAmount>
                     <displayPrice>1766.16</displayPrice>
                     <optionPrice>1766.16</optionPrice>
                     <attributes/>
                     <id>126907849152</id>
                     <quantity>150</quantity>
                     <version>4</version>
                  </stockItem>
               </stockItems>
               <subtitle>test ürün 2</subtitle>
               <title>Test Ürün</title>
               <unitInfo/>
            </product>
         </products>
         <pagingData>
            <currentPage>0</currentPage>
            <pageSize>100</pageSize>
            <totalCount>1</totalCount>
            <pageCount>1</pageCount>
         </pagingData>
      </ns3:GetProductListResponse>
   </env:Body>
</env:Envelope>

C# Code C# 代码

 public async Task<IList<ProductBasic>> GetProducts(N11PagingModel n11PagingModel)
        {
            var authentication = GetAuthentication();
            var client = new ProductServicePortClient();
            
            var response = await client.GetProductListAsync(new GetProductListRequest { auth = authentication, pagingData = n11PagingModel.Map<RequestPagingData>() });

            var result = response.GetProductListResponse.result;
                          
            if (result.status == "success")
            {
                var products = response.GetProductListResponse.products?.ToList();
                return products;
            }
            else
            {
                return null;
            }
        }

Change:改变:

[System.ServiceModel.XmlSerializerFormatAttribute(Style=System.ServiceModel.OperationFormatStyle.Rpc, SupportFaults=true, Use=System.ServiceModel.OperationFormatUse.Encoded)]

To

[System.ServiceModel.XmlSerializerFormatAttribute(Style=System.ServiceModel.OperationFormatStyle.Document, SupportFaults=true, Use=System.ServiceModel.OperationFormatUse.Literal)]

I am taking a shot in the dark here but I think the issue is that you are trying to read the same response stream twice by calling the following twice:我在这里在黑暗中拍摄,但我认为问题是您试图通过调用以下两次来读取相同的响应 stream 两次:

response.GetProductListResponse

Instead try:而是尝试:

public async Task<IList<ProductBasic>> GetProducts(N11PagingModel n11PagingModel)
        {
            var authentication = GetAuthentication();
            var client = new ProductServicePortClient();
            
            var response = await client.GetProductListAsync(new GetProductListRequest { auth = authentication, pagingData = n11PagingModel.Map<RequestPagingData>() });

            var responseObject = response.GetProductListResponse;
                          
            if (responseObject.result.status == "success")
            {
                var products = responseObject.products?.ToList();
                return products;
            }
            else
            {
                return null;
            }
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用HttpClient将Zip文件上传到ASP.NET Core WebAPI服务,但IFormData参数始终为null - Upload Zip files to ASP.NET Core WebAPI service with HttpClient but IFormData argument is always null 无法对ASP.NET Core中的SOAP服务进行身份验证 - Can't authenticate towards SOAP service in ASP.NET Core Asp.net核心,HttpClient通过POST请求到达SOAP服务 - Asp.net core, HttpClient to reach SOAP service with POST request 在asp.net核心实现SOAP 1.2服务 - Implement SOAP 1.2 service in asp.net core ASP.Net Core Web应用程序POST方法始终接收NULL作为参数 - ASP.Net Core web app POST method always receives NULL as a parameter ASP.NET 内核 3.1 | 参数 model 总是 null 与 controller 动作方法中的大表格数据 - ASP.NET Core 3.1 | Argument model always null with large form data in controller action method ASP.Net Core 3.1:控制器方法总是从 HttpPost 调用接收 NULL 参数 - ASP.Net Core 3.1: Controller method always recieves NULL parameter from HttpPost call 从 ASP.NET Core Web 方法提供 SOAP - Serve SOAP from ASP.NET Core web method 使用 Asp.Net Core 将参数传递给 soap 方法 SOAPCORE - Passing parameter to soap method SOAPCORE with Asp.Net Core ASP.NET Core 1依赖注入:实现类型始终为null - ASP.NET Core 1 Dependency Injection: Implementation type always null
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM