magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.51k stars 9.31k forks source link

Error in Magento SOAP API calls from C#.Net #9604

Closed Ramzzzz closed 7 years ago

Ramzzzz commented 7 years ago

Trying to consume Magento 2.0 SOAP in C# using visual studio 2013. Soap Url: http://localhost:85/Magento-Siemens/soap/default?services=catalogProductRepositoryV1 Error: Error in deserializing body of reply message for operation 'catalogProductRepositoryV1Get'

Code: var proxy= new catalogProductRepositoryV1PortTypeClient(); var response = new CatalogProductRepositoryV1GetResponse(); var request = new CatalogProductRepositoryV1GetRequest { sku = "ABC", editMode = false, editModeSpecified = true, forceReload = true, forceReloadSpecified = true, storeId = 0, storeIdSpecified = true }; using (var scope = new OperationContextScope(proxy.InnerChannel)) { try { var httpRequestProperty = new HttpRequestMessageProperty(); httpRequestProperty.Headers[System.Net.HttpRequestHeader.Authorization] = "Bearer " + AccessToken; OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty; response = proxy.catalogProductRepositoryV1Get(request); } catch (Exception ex) { var sd = ex.Message; } }

Error: image

Client Config:

        <customBinding>
            <binding name="catalogProductRepositoryV1Binding"  closeTimeout="12:01:00"
      openTimeout="12:01:00" receiveTimeout="12:10:00" sendTimeout="12:01:00" >
                <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
  messageVersion="Soap12" writeEncoding="utf-8">
                  <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                maxNameTableCharCount="2147483647" />
              </textMessageEncoding>
                <httpTransport />
            </binding>
        </customBinding>

Help will be greatly appreciated. Thank You.

rparsi-commer commented 7 years ago

@Ramzzzz Wouldn't it be easier to use the Rest Api instead?

Ramzzzz commented 7 years ago

No, actually, it is much easier to use SOAP, as it exposes required classes through proxy :) Anyway, I updated to Magento ver 2.1.6. Currently, I don't see any more error related to xml deserialization.

rparsi-commer commented 7 years ago

@Ramzzzz You're the first php dev I've come across that actually likes SOAP lol. I've always hated it, annoying to work with in code.

korostii commented 7 years ago

The topic implies he's not a php dev, actually =D

SOAP API calls from C#.Net

Higher-level languages like C# and java actually allow you to generate a bunch of proxy classes based purely on WSDL, including the all the methods, parameters expected etc. which saves a lot of time. REST doesn't have any kind of uniform schema and thus it's not enough to provide a single endpoint: you'll need to manually each of the exact endpoints for every API method you use.

rparsi-commer commented 7 years ago

@korostii I thought he's a php dev lolz Personally I prefer C# over Java. While we're totally off topic, you think the open source dot Net will take over php someday? https://github.com/dotnet/core

korostii commented 7 years ago

Well, as a language, PHP has its disadvantages, but most of the time it's just enough to fulfill the task at hand. And there are multiple forces at hand and most of the time business constraints and available libraries\frameworks etc. play a bigger role than the perks language has.

For example, it's been years and there are still some COBOL and Delphi apps used here and there, sometimes it's just much cheaper to support and old but well tested application rather than throw it away and re-implement it from scratch.

PHP has well grown into its niche, and it's a large one. Sure, parts of the web will get overtaken by different players, but, to be honest, I don't think PHP will get completely replaced anytime soon.

magento-engcom-team commented 7 years ago

Hi @Ramzzzz could you please let us know if the issue still exists on latest 2.2.0 release?

Ramzzzz commented 7 years ago

Nope.. issue doesn't exist anymore in 2.2.0 release. Thanks.