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.59k stars 9.32k forks source link

Magento2 SOAP API #2002

Closed VLCSolutions closed 9 years ago

VLCSolutions commented 9 years ago

How to create a SOAP API in magento2

okorshenko commented 9 years ago

Hi @VLCSolutions , please look at API Documentaion. If you have additional questions, please, let us know

VLCSolutions commented 9 years ago

If possible could you please elaborate with a example please

okorshenko commented 9 years ago

@VLCSolutions, to create new SOAP API you need to declare interface (for example: https://github.com/magento/magento2/blob/develop/app/code/Magento/Customer/Api/GroupRepositoryInterface.php) and configure it in webapi.xml (for example: https://github.com/magento/magento2/blob/develop/app/code/Magento/Customer/etc/webapi.xml#L12). This logic will be available in REST and SOAP API. For more details please refer Sample WebAPI

VLCSolutions commented 9 years ago

@okorshenko thanks for reply, where we define the elements or attributes for the request and response elements like how we defined in wsdl.xml file in magento1. Please bare me...

okorshenko commented 9 years ago

@VLCSolutions , currently you don't need to configure attributes separately. Your interface returns object (let's say, customer group https://github.com/magento/magento2/blob/develop/app/code/Magento/Customer/Api/GroupRepositoryInterface.php#L32). \Magento\Customer\Api\Data\GroupInterface has declared getters that will be transformed to response attributes. (https://github.com/magento/magento2/blob/develop/app/code/Magento/Customer/Api/Data/GroupInterface.php#L20-L23)

VLCSolutions commented 9 years ago

@okorshenko , What is difference between https://github.com/magento/magento2/blob/develop/app/code/Magento/Customer/etc/webapi.xml#L113-L118 and https://github.com/magento/magento2/blob/develop/app/code/Magento/Customer/etc/webapi.xml#L140-L148

choukalos commented 9 years ago

the /me means that you only get your information ( authorized with a customer token ) - you can't use that web api to get any other customer from the system like you can with the first web api ( which requires an admin token ).

VLCSolutions commented 9 years ago

@okorshenko , @choukalos : how to create multiple customers at a time, for example \Magento\Customer\Api\Data\CustomerRepository save method accepts only one customer details at a time to save, but i want to create multiple customers on one API request.

And what is the importance of KEY keyword in api, example https://github.com/magento/magento2/blob/develop/app/code/Magento/Customer/Api/Data/CustomerInterface.php#L35 compared to other attributes which do not have KEY keyword

choukalos commented 9 years ago

We only support single entity APIs; there's no plan to support bulk API calls in our framework.

For higher volume integrations we'll be enhancing scheduled FTP's to be more like a feeds system where you can configure scheduled FTP/SFTP transfer via XML as part of your extension. Likely this will be in the later half of 2016. Thinking behind that is it'll allow transfer for very large catalogs, inventory updates, etc in a more performant manner than supporting bulk API calls. This feature will be in enterprise.

VLCSolutions commented 9 years ago

@choukalos , thanks for reply. Please help me on getting WSDL structure for SOAP API. Like CustomerRequest able to request from SoapUI.

VLCSolutions commented 9 years ago

@okorshenko , @choukalos Please help me on getting WSDL XML structure for any API request in magento2. In magento1 i could able to get the WSDL XML structure in SOAPUI or storm by giving SOAP URL, But in magento2 i'm not able to get WSDL XML structure, please help me on this.

alankent commented 9 years ago

Are you saying fetching WSDL does not work, or you do not know how to do it? Have you had a look at http://devdocs.magento.com/guides/v2.0/soap/bk-soap.html ? That lists lots of end points for fetching WSDL. If it is not working, could you provide more details on what error messages etc you are getting? Thanks!

VLCSolutions commented 9 years ago

@alankent I want to get XML request for customerrepository API, For this i have used http://192.168.0.183/NewMagento2/soap?wsdl&services=customerCustomerRepositoryV1 in SOAPUI tool and i'm getting error

http://192.168.0.183/NewMagento2/soap?wsdl&services=customerCustomerRepositoryV1 loading http://192.168.0.183/NewMagento2/soap?wsdl&services=customerCustomerRepositoryV1 Acquiring the wsdl... Resolving the wsdlendpoint... Generating code... Code generation failed. Microsoft.FSharp.Core.FailureException: Assembly not yet created. at Storm.Types.WebSvcManagerOps.clo@90.CreateWebServiceModel() at <StartupCode$Storm>.$Type.bgworker.run@51@57_2.Invoke(DoWorkEventArgs dArgs) at <StartupCode$Storm>.$Type.bgworker.run@51@57_1.Invoke(Object sender, DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)

choukalos commented 9 years ago

Internally tracking - MAGETWO-43797

arkadiych commented 9 years ago

@VLCSolutions, I'm trying to reproduce your error. Could you provide more details about the environment, where you ran your XML request: the version of SOAPUI, what kind of tool do you use to generate code, the version of the tool, language of generated code, protocol? Was you able to get results using the approach described in http://www.soapui.org/soap-and-wsdl/getting-started.html with http://192.168.0.183/NewMagento2/soap?wsdl&services=customerCustomerRepositoryV1 ?

VLCSolutions commented 9 years ago

@arkadiych Now i'm able to get request and response XML structure from SOAPUI tool, but when i try to use the same http://192.168.0.183/NewMagento2/soap?wsdl&services=customerCustomerRepositoryV1 in storm tool still its giving error. Note: In Storm magento1 XML Request generated successfully.

arkadiych commented 9 years ago

@VLCSolutions, looks like Storm supports SOAP1.1, but not SOAP1.2 for code generation. Magento2 SOAP Web Service supports SOAP1.2

davidalger commented 9 years ago

Closing issue due to the issue being related to SOAP version incompatibly. Feel free to reopen this if there is a bug in Magento 2, but please provide more details on reproducing the precise issue.

The GitHub issue tracker is intended for technical issues only. Please refer to the Community Forums or Magento Stack Exchange site for technical questions. In your case, the programming questions forum is likely the most appropriate. Feel free to reopen this issue if you think you have encountered a bug in Magento 2.