Click here to Skip to main content
15,897,371 members

Specifying a WCF SOAP response has 0 or more elements?

cjb110 asked:

Open original thread
I'm writing a WCF client (that will be in a COM component) so I can't use Service References.
I've had to take the WSDL generated classes and alter them so that the right SOAP format is passed.

I've got the sending working, but I'm not able to process the response properly.

I think its because the response can contain 0 or more repeated elements and my classes don't have the right attributes set.

So the response I'm receiving (determined using Fiddler):
XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:oug="http://ougwebcomponent.components.oug.osgi.scorex.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <oug:ougWSResponse>
         <data_flux>
            <item>wf_rc</item>
            <item>999</item>
         </data_flux>
         <data_flux>
            <item>wf_rc_desc</item>
            <item>Component execution complete but an unexpected Exception occurred</item>
         </data_flux>
         <data_flux>
            <item>wf_component</item>
            <item>xslt</item>
         </data_flux>
      </oug:ougWSResponse>
   </soapenv:Body>
</soapenv:Envelope>


So as you can see the data_flux is repeated.

The response method and data_flux is defined in my code as:
C#
[MessageContractAttribute(WrapperName = "ougWSResponse", WrapperNamespace = "http://ougwebcomponent.components.oug.osgi.scorex.com/", IsWrapped = true)]
    public partial class ougWSResponse
    {

        [MessageBodyMemberAttribute(Namespace = "http://ougwebcomponent.components.oug.osgi.scorex.com/", Order = 0)]
        [XmlElementAttribute("data_flux", Form = System.Xml.Schema.XmlSchemaForm.None)]
        public stringArray[] data_flux;

        public ougWSResponse() { }
        public ougWSResponse(stringArray[] data_flux)
        {
            this.data_flux = data_flux;
        }
    }
    [SerializableAttribute()]
    [XmlTypeAttribute(Namespace = "http://jaxb.dev.java.net/array", IncludeInSchema=false)]
    public partial class stringArray : object, INotifyPropertyChanged
    {

        private string[] itemField;

        [XmlElementAttribute("item", Form = System.Xml.Schema.XmlSchemaForm.None, Order = 0)]
        public string[] item
        {
            get
            {
                return this.itemField;
            }
            set
            {
                this.itemField = value;
                this.RaisePropertyChanged("item");
            }
        }
        
        //...snipped INPC stuff
    }


I think its either the attributes or the ougWSResponse class definition that's wrong.

Any pointers or articles to check would be great. I do find attributes to have the most useless documentation (that concentrates on their definition and not what most people want their usage!)
Tags: C# (C# 4.0), WCF, SOAP

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900