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 8965721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:52:16+00:00 2026-06-15T16:52:16+00:00

I’ve received a specification from a customer of how their web-service client works. The

  • 0

I’ve received a specification from a customer of how their web-service client works. The specification is the actual SOAP XML messages that are sent and received from the service as well as the corresponding XSD. The customer want me to implement a web-service that comply with the client. The client is written with axis2 ws-stack and what i’m trying to do is to create a web-service in WCF that will accept the requests made by the client and return a response that comply with the XML that they are expecting. In this question I will only post the XML and XSD associated with the request, because if I can get that to work, the response will be made in a similar fashion.

The XML I’ve received is the following:

POST /axis2/services/SampleService HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: "sendCommand"
User-Agent: Axis2
Host: 127.0.0.1:7777
Content-Length: 347
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
   <soapenv:Body> 
      <SendCommandRequest xmlns="http://something.org/"> 
         <CMD> 
            <Station Address="ABC"> 
               <Platform Address="DEF"> 
                  <Command>5</Command> 
               </Platform> 
             </Station> 
         </CMD> 
       </SendCommandRequest> 
    </soapenv:Body>
</soapenv:Envelope>

This is what the corresponding XSD looks like:

<xsd:complexType name="SendCommandRequestType"> 
    <xsd:sequence>  
        <xsd:element name="Station"> 
            <xsd:complexType> 
                <xsd:attribute name="Address" type="xsd:string" use="required" /> 
                <xsd:sequence> 
                    <xsd:element minOccurs="0" maxOccurs="1" name="Platform"> 
                        <xsd:complexType> 
                            <xsd:attribute name="Address" type="xsd:string" use="required" /> 
                            <xsd:sequence> 
                                <xsd:element name="Command"> 
                                    <xsd:simpleType> 
                                        <xsd:restriction base="xsd:string"> 
                                            <xsd:enumeration value="-1"/> 
                                            <xsd:enumeration value="0"/> 
                                            <xsd:enumeration value="1"/> 
                                            <xsd:enumeration value="2"/> 
                                            <xsd:enumeration value="3"/> 
                                            <xsd:enumeration value="4"/> 
                                            <xsd:enumeration value="5"/> 
                                        </xsd:restriction> 
                                    </xsd:simpleType> 
                                </xsd:element> 
                            </xsd:sequence> 
                        </xsd:complexType> 
                    </xsd:element> 
                </xsd:sequence> 
            <xsd:complexType>
        </xsd:element>
    </xsd:sequence>
</xsd:complexType>

I’ve started to write the types in WCF/MessageContract format, but I’m having a difficult time with lists etc, since they are double wrapped.

My MessageContracts looks like this:

[MessageContract(WrapperName = "SendCommandRequest", WrapperNamespace = "http://something.org/")]
public class SendCommandRequest
{
    [MessageBodyMember(Name="CMD")]
    public CMD cmd = new CMD();
}

[MessageContract(IsWrapped=false)]
public class CMD
{
    [MessageBodyMember(Name="Station")]
    public List<Station> stations = new List<Station>();
}

[MessageContract(IsWrapped=false)]
public class Station
{

    [MessageBodyMember]
    public List<Platform> platforms = new List<Platform>();
    [MessageBodyMember(Name="Address")]
    public String Address; 
}

[MessageContract(WrapperName = "Platform")]
public class Platform
{
    [MessageBodyMember(Name = "Address")]
    public String Address;
}

When I use SoapUI to I get the following response from the web-service:

 <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <SendCommandRequest xmlns="http://ttraflinariawebservice.org/">
         <CMD xmlns="http://tempuri.org/" xmlns:a="http://schemas.datacontract.org/2004/07/GeldImport" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <a:stations>
               <a:Station>
                  <a:Address>test</a:Address>
                  <a:platforms>
                     <a:Platform>
                        <a:Address>b</a:Address>
                     </a:Platform>
                  </a:platforms>
               </a:Station>
            </a:stations>
         </CMD>
      </SendCommandRequest>
   </s:Body>
</s:Envelope>

As you can see it doesn’t fit the XML format that the client expects. How can I get the MessageContract to comply with the XML that the client expects? I somehow need to make Lists not double wrap like they do, and the properties of the classes seems to be added to the class name.

If you want me to provide more information and code I can do so. Didn’t want to fill the whole post with things which might not be relevant to the question.

EDIT:

The provided XSD file was not well formatted. In order to solve this i regenerated an XSD from the provided XML file. I then used WSCF.blue tool to generate data contract code for the XSD.

I changed so that the service contract used doc litteral formatting to comply with axis2 soap1.1

[XmlSerializerFormat(Use = OperationFormatUse.Literal, Style = OperationFormatStyle.Document, SupportFaults = true)]
[ServiceContract]
public interface MyService

I also changed the operation contract to have System.ServiceModel.Channels.Message as input and output message and then manually serialized and deserialized the xml using the generated classes (which I generated from the XSD).

  • 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-15T16:52:17+00:00Added an answer on June 15, 2026 at 4:52 pm

    Your prolem with the original attempt is that you’re trying to use [MessageContract] classes to define the data contract (schema) of the message. Message contracts are only used as the top-most classes (to define what goes into the message header and what goes into the body). The other classes need to use the attributes for whichever serializer you’re using (and since you have XML attributes, you need to use the XmlSerializer). The code below shows how to get an object model compliant with the schema you provided. You can use a tool such as Fiddler to see the request it sends.

    public class StackOverflow_13739729
    {
        [ServiceContract(Namespace = "http://something.org")]
        public interface ITest
        {
            [XmlSerializerFormat, OperationContract(Name = "sendCommand")]
            void SendCommand(SendCommandRequest req);
        }
    
        public class Service : ITest
        {
            public void SendCommand(SendCommandRequest req)
            {
                Console.WriteLine("In service");
            }
        }
    
        [MessageContract(WrapperName = "SendCommandRequest", WrapperNamespace = "http://something.org")]
        public class SendCommandRequest
        {
            [MessageBodyMember]
            public CMD CMD { get; set; }
        }
    
        [XmlType]
        public class CMD
        {
            [XmlElement]
            public Station Station { get; set; }
        }
    
        public class Station
        {
            [XmlAttribute]
            public string Address { get; set; }
    
            [XmlElement]
            public Platform Platform { get; set; }
        }
    
        public class Platform
        {
            string[] validCommands = new[] { "-1", "0", "1", "2", "3", "4", "5" };
            string[] command;
    
            [XmlAttribute]
            public string Address { get; set; }
    
            [XmlElement]
            public string[] Command
            {
                get { return this.command; }
                set
                {
                    if (value != null)
                    {
                        if (!value.All(c => validCommands.Contains(c)))
                        {
                            throw new ArgumentException("Invalid command");
                        }
                    }
    
                    this.command = value;
                }
            }
        }
    
        public static void Test()
        {
            string baseAddress = "http://" + Environment.MachineName + ":8000/Service";
            ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress));
            host.AddServiceEndpoint(typeof(ITest), new BasicHttpBinding(), "");
            host.Open();
            Console.WriteLine("Host opened");
    
            ChannelFactory<ITest> factory = new ChannelFactory<ITest>(new BasicHttpBinding(), new EndpointAddress(baseAddress));
            ITest proxy = factory.CreateChannel();
    
            SendCommandRequest req = new SendCommandRequest
            {
                CMD = new CMD
                {
                    Station = new Station
                    {
                        Address = "ABC",
                        Platform = new Platform
                        {
                            Address = "DEF",
                            Command = new string[] { "5" }
                        }
                    }
                }
            };
    
            proxy.SendCommand(req);
    
            ((IClientChannel)proxy).Close();
            factory.Close();
    
            Console.Write("Press ENTER to close the host");
            Console.ReadLine();
            host.Close();
        }
    }
    
    • 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'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm interested in microtypography issues on the web. I want a tool to fix:

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.