I have tried for a while to get the Magento API via soap to work in VS2015 4.6 VB.net both web and win with no success.

I have the wsdl recognized but can't get a session id returned with login.

When using ....

    Dim mag1 As New mag.PortTypeClient
    Dim sessid = mag1.login("xxxxx", "xxxxxxxxx")

I receive the error "Invalid XML"

Didn't know if I could correspond with someone who has been successful with this.

thanks mark


Yes I have it working - I had to increase the message size and set time-out settings in order to get it functioning properly but it works. I also found that the SoapV2 speed is very slow unless caching is turned on under general API settings in Magento. Here is my code - Obviously you need to fill in the correct address for the endpoint and appropriate login credentials and make sure you have added the reference as a Service Reference, not a Web Reference, it does make a difference:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

'Set up endpoint binding with increased buffer / pool / quota sizes'
Dim EPAddress As EndpointAddress = New EndpointAddress("https://[magento host name]/api/v2_soap")
Dim binding As BasicHttpsBinding = New BasicHttpsBinding
binding.CloseTimeout = New TimeSpan(0, 0, 1, 0)
binding.OpenTimeout = New TimeSpan(0, 0, 1, 0)
binding.ReceiveTimeout = New TimeSpan(0, 0, 10, 0)
binding.SendTimeout = New TimeSpan(0, 0, 1, 0)
binding.AllowCookies = False
binding.BypassProxyOnLocal = False
binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard
binding.MaxBufferSize = 20000000
binding.MaxBufferPoolSize = 20000000
binding.MaxReceivedMessageSize = 20000000
binding.MessageEncoding = WSMessageEncoding.Text
binding.TextEncoding = Encoding.UTF8
binding.TransferMode = TransferMode.Buffered
binding.UseDefaultWebProxy = True

Dim Quotas As New XmlDictionaryReaderQuotas
Quotas.MaxDepth = 20000000
Quotas.MaxStringContentLength = 20000000
Quotas.MaxArrayLength = 20000000
Quotas.MaxBytesPerRead = 20000000
Quotas.MaxNameTableCharCount = 20000000
binding.ReaderQuotas = Quotas

binding.Security.Mode = BasicHttpSecurityMode.None
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None
binding.Security.Transport.Realm = ""

binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName
binding.Security.Message.AlgorithmSuite = SecurityAlgorithmSuite.Default

'Create the service object using the binding settings above and appropriate end point address'
Dim ServiceClient As PortTypeClient = New PortTypeClient(binding, EPAddress)

'Make the login() call and get a Session ID'
Dim SessionID As String = ServiceClient.login("[Username]", "[APIKey]")
  • If you're having slow API calls check into autoloader class path cache, I've seen a usual reduction of response time by around 75,% just be very diligent in regression testing before using it as it rewrites a core piece, and composer needs to be considered as well. github.com/AOEpeople/Aoe_ClassPathCache
    – B00MER
    Apr 12 '17 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.