0

I'am using a SOAP service. In the asp.net core project as connected service. Soap UI populated response. But not populated my method in the asp.net core.

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! response for .net View image

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

 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;
            }
        }

2 Answers2

1

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 almost lost my mind with a similar case. I hadn't realized that the problem was in the response deserialization. – Yasel Nov 24 '20 at 19:24
0

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:

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;
            }
        }
DonO
  • 1,030
  • 1
  • 13
  • 27
  • Hi @DonO, Thanks for the answer. But the "result" found there does not come from the task. A piece of soap response. So there seems to be no problem with the c# code. – bilgibilisim Oct 10 '20 at 15:09
  • @bilgibilisim have you found a solution that return null from n11 service ? – S. Aziz Kazdal Mar 19 '21 at 11:52