Click here to Skip to main content
15,907,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am consuming JAVA web service in C# application. I want to generate request object in XML like below.

XML
<soapenv:Envelope
            xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns:web="http://webservice.api.cabaret.com/"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <soapenv:Header/>
   <soapenv:Body>
      <web:callArgs>
         <name></name>
         <args>
            <entries>
               <name>locator.content</name>
               <value xsi:type="xs:string">AA==</value>
            </entries>
            <entries>
               <name>locator.name</name>
               <value xsi:type="xs:string">Reha0850.pdf</value>
            </entries>
         </args>
      </web:callArgs>
   </soapenv:Body>
</soapenv:Envelope>


But my XML generate like below.

XML
{<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header />
  <s:Body>
    <callArgs xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/PDFFieldReader.SignLiveSrv">
      <PropertyChanged xmlns:d4p1="http://schemas.datacontract.org/2004/07/System.ComponentModel" i:nil="true" />
      <argsField>
        <mapEntry>
          <PropertyChanged xmlns:d6p1="http://schemas.datacontract.org/2004/07/System.ComponentModel" i:nil="true" />
          <nameField>locator.content</nameField>
          <valueField xmlns:d6p1="http://www.w3.org/2001/XMLSchema" i:type="d6p1:base64Binary">AA==</valueField>
        </mapEntry>
      </argsField>
      <nameField>urn:callArgs</nameField>
    </callArgs>
  </s:Body>
</s:Envelope>}


I used the following classes as a stub and serialize them.

C#
namespace PDFFieldReader.SignLiveSrv {
     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.6.1064.2")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://webservice.api.cabaret.com/")]
    public partial class mapEntry : object, System.ComponentModel.INotifyPropertyChanged {

        private string nameField;

        private object valueField;

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
        public string name {
            get {
                return this.nameField;
            }
            set {
                this.nameField = value;
                this.RaisePropertyChanged("name");
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)]
        public object value {
            get {
                return this.valueField;
            }
            set {
                this.valueField = value;
                this.RaisePropertyChanged("value");
            }
        }

        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChanged(string propertyName) {
            System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
            if ((propertyChanged != null)) {
                propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
    }

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.6.1064.2")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://webservice.api.cabaret.com/")]
    public partial class callArgs : object, System.ComponentModel.INotifyPropertyChanged {

        private string nameField;

        private mapEntry[] argsField;

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
        public string name {
            get {
                return this.nameField;
            }
            set {
                this.nameField = value;
                this.RaisePropertyChanged("name");
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)]
        [System.Xml.Serialization.XmlArrayItemAttribute("entries", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
        public mapEntry[] args {
            get {
                return this.argsField;
            }
            set {
                this.argsField = value;
                this.RaisePropertyChanged("args");
            }
        }

        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChanged(string propertyName) {
            System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
            if ((propertyChanged != null)) {
                propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
    }

}


What I have tried:

I am using channel programming to call the webservice as below.

C#
IChannelFactory<IRequestChannel> factory = binding.BuildChannelFactory<IRequestChannel>(bindingParams);
            factory.Open();

EndpointAddress endPointAddress = new EndpointAddress("http://10.32.137.65:8888/SignatureService/");            IRequestChannel channel = factory.CreateChannel(endPointAddress);
            channel.Open();

            

            System.ServiceModel.Channels.Message requestMessage = System.ServiceModel.Channels.Message.CreateMessage(MessageVersion.Soap11, "urn:callArgs", objMapEntry);


Above CreateMessage not giving me the expected soap message mentioned above.

Please help me out to resolve this .

Thanks & Regards,

Suraj
Posted
Updated 11-Mar-16 21:42pm

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



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