Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9128985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:38:41+00:00 2026-06-17T07:38:41+00:00

I’m using VB.NET to communicate with Magento via the API SOAP v1. I had

  • 0

I’m using VB.NET to communicate with Magento via the API SOAP v1. I had it working fine until I got to a call that needed an associative array. I’ve tried dictionaries, hashtables, custom types, etc. I did read hashtables and dictionaries are not serializable. So I tried the custom type/object/class. Below is the error I received:

The type XXXX was not expected. Use the Xmlinclude or SoapInclude attribute to specify types that are not known statically.

So I’ve read a lot of posts in regards to the above error and I can’t get anything to work. The error seems at least to say what I’m trying is possible if I do it right, but maybe that is not the case. I don’t know much about SOAP, but I can see this never working since the web service might not know how to handle the object.

So my question is if it’s possible to send a custom object to the Magento API. Or more broadly is it possible to get SOAP v1 to work with VB.NET. I know v2 is an option but I’m pretty familiar with v1 and already having it working in VB.NET other than this scenario.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:38:42+00:00Added an answer on June 17, 2026 at 7:38 am

    It took a lot of digging, but I have it all working. To start I used the PHP SoapClient and noted how it formed associative arrays in the soap request. You can trace requests and responses, pretty handy. From there I wrote my own soap client in VB.NET using a WebRequest object. In doing so I have full control over the xml being sent to the API.

    Again the reason I went down this road is ultimately V2 was not working for me. For some reason not all parameters were making it to the API. That and the fact I’m pretty comfortable with V1 too. I’ve written several custom APIs.

    I apologize for the brevity, but there is a lot that went into this. Probably most of my time was hitting multiple dead ends. If anyone wants specifics feel free email me.

    EDIT:

    Here is the php code I used to see how I needed to format the requests:

    $client = new SoapClient('http://www.site.com/index.php/api/soap/?wsdl',array('trace' => TRUE));
    $session = $client->login('user','api-key');
    
    echo $client->__getLastRequest() ."\n\n";
    echo $client->__getLastRequestHeaders() ."\n\n";
    echo $client->__getLastResponse() ."\n\n";
    echo $client->__getLastResponseHeaders() ."\n\n";
    
    $result = $client->call($session, 'cataloginventory_stock_item.list','393');
    
    echo $client->__getLastRequest() ."\n\n";
    echo $client->__getLastRequestHeaders() ."\n\n";
    
    var_dump($result);
    $client->endSession($session);
    

    Below is how to send the request using VB.NET. You will need to construct the XML/SOAP body using the php above as a guide. I made a class per API call which output the needed XML. You will need System.Net, System.Xml & System.IO. I used getSoapHeader() because there is some common XML that goes into a request. See next code section for more details:

        Private Function makeSoapRequest(ByVal soapBody As String) As String
    
        Dim req As WebRequest = WebRequest.Create(_soap_url)
        Dim xml As String
    
        xml = getSoapHeader() & soapBody
    
        Dim buffer() As Byte = System.Text.Encoding.UTF8.GetBytes(xml)
        req.ContentType = "text/xml; charset=utf-8"
        req.Method = "POST"
    
        req.Headers.Add("SOAPAction", "urn:Mage_Api_Model_Server_HandlerAction")
        req.ContentLength = buffer.Length
    
        Dim st As System.IO.Stream = req.GetRequestStream
    
        st.Write(buffer, 0, buffer.Length)
        st.Close()
    
        Dim response As WebResponse
    
        Try
            response = req.GetResponse
        Catch ex As WebException
            response = ex.Response
        End Try
    
        st = response.GetResponseStream()
    
        Dim reader As New StreamReader(st)
    
        Dim responseFromServer As String = reader.ReadToEnd()
    
        makeSoapRequest = responseFromServer
    
        response.Close()
        st.Close()
    
    End Function
    

    Below is the getSoapHeader() function. As noted the ns2 portion is only needed if you are using type=”ns2:Map” which is what I needed for associative arrays:

        Private Function getSoapHeader() As String
        'ns2 is not always needed
        getSoapHeader = "<?xml version=""1.0"" encoding=""UTF-8""?><SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:ns1=""urn:Magento"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:SOAP-ENC=""http://schemas.xmlsoap.org/soap/encoding/"" xmlns:ns2=""http://xml.apache.org/xml-soap"" SOAP-ENV:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/""> " & vbCrLf
    
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am using JSon response to parse title,date content and thumbnail images and place
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.