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

  • SEARCH
  • Home
  • 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 8413543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:56:20+00:00 2026-06-10T00:56:20+00:00

I’m using JavaScript to communicate to a WCF service via XML (I can’t use

  • 0

I’m using JavaScript to communicate to a WCF service via XML (I can’t use JSON). This has been working well so far for WCF methods which expose arguments of “primitive” data types, but now I need to call a WCF method which accepts an array. I’ve been unable to figure out how to tweak my XML properly.

For example, a WCF method with two parameters accepts:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <MySimpleMethod xmlns="http://tempuri.org/">
      <parameter1>value</parameter1>
      <parameter2>someOtherValue</parameter2>
    </MySimpleMethod>
  </s:Body>
</s:Envelope>

I thought I might be able to pass an array (of strings in this case) by doing the following:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <MyMethodWithAnArrayParameter xmlns="http://tempuri.org/">
      <arrayParameterName>value1</arrayParameterName>
      <arrayParameterName>value2</arrayParameterName>
    </MyMethodWithAnArrayParameter>
  </s:Body>
</s:Envelope>

But this hasn’t worked. If anyone has any insight I’d be very appreciative.

Thanks.

EDIT:

Making progress. Darin’s answer works for primitive data types, but I’m unable to pass something more complex, say an array of the following class:

public class Address 
{
    public String Number {get; set;};
    public String City {get; set;};
    public String State {get; set;};
}

I’ve tried this:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <TestMethod xmlns="http://tempuri.org/">
      <args xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <a:Address>
          <Number>31</Number>
          <City>Houston</City>
          <State>Texas</State>
        </a:Address>
      </args>
    </TestMethod>
  </s:Body>
</s:Envelope>

The method gets called (I can verify this in a debugger), but the array that it gets passed is empty.

  • 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-10T00:56:21+00:00Added an answer on June 10, 2026 at 12:56 am

    Assuming the following method signature exposed over a basicHttpBinding:

    [OperationContract]
    string MyMethodWithAnArrayParameter(string[] values, string parameter2);
    

    you could invoke like this:

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        <s:Body>
            <MyMethodWithAnArrayParameter xmlns="http://tempuri.org/">
                <values xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                    <a:string>value1</a:string>
                    <a:string>value2</a:string>
                </values>
                <parameter2>param2</parameter2>
            </MyMethodWithAnArrayParameter>
        </s:Body>
    </s:Envelope>
    

    UPDATE:

    Assuming the following operation contract:

    [OperationContract]
    string TestMethod(Address[] args);
    

    The request could look like this

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        <s:Body>
            <TestMethod xmlns="http://tempuri.org/">
                <args xmlns:a="http://schemas.datacontract.org/2004/07/WcfService1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                    <a:Address>
                        <a:City>Houston</a:City>
                        <a:Number>31</a:Number>
                        <a:State>Texas</a:State>
                    </a:Address>
                    <a:Address>
                        <a:City>Washington</a:City>
                        <a:Number>21</a:Number>
                        <a:State>DC</a:State>
                    </a:Address>
                </args>
            </TestMethod>
        </s:Body>
    </s:Envelope>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
Does anyone know how can I replace this 2 symbol below from the string
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.