locked
Help Needed in Xml Parsing RRS feed

  • Question

  • User1489758560 posted

    Hi,

    I am trying to call web service with no proxy and i am able to achieve it. below the wrapper am using to call the service.

    public static class SOAPHelper
        {
            /// <summary>
            /// Sends a custom sync SOAP request to given URL and receive a request
            /// </summary>
            /// <param name="url">The WebService endpoint URL</param>
            /// <param name="action">The WebService action name</param>
            /// <param name="parameters">A dictionary containing the parameters in a key-value fashion</param>
            /// <param name="soapAction">The SOAPAction value, as specified in the Web Service's WSDL (or NULL to use the url parameter)</param>
            /// <param name="useSOAP12">Set this to TRUE to use the SOAP v1.2 protocol, FALSE to use the SOAP v1.1 (default)</param>
            /// <returns>A string containing the raw Web Service response</returns>
            public static string SendSOAPRequest(string url, string action, Dictionary<string, string> parameters, string soapAction = null, bool useSOAP12 = false)
            {
                // Create the SOAP envelope
                XmlDocument soapEnvelopeXml = new XmlDocument();
                var xmlStr = (useSOAP12)
                    ? @"<?xml version=""1.0"" encoding=""utf-8""?>
                        <soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
                          xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
                          xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">
                          <soap12:Body>
                            <{0} xmlns=""{1}"">{2}</{0}>
                          </soap12:Body>
                        </soap12:Envelope>"
                    : @"<?xml version=""1.0"" encoding=""utf-8""?>
                        <soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""
                            xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
                            xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
                            <soap:Body>
                               <{0} xmlns=""{1}"">{2}</{0}>
                            </soap:Body>
                        </soap:Envelope>";
                string parms = string.Join(string.Empty, parameters.Select(kv => String.Format("<{0}>{1}</{0}>", kv.Key, kv.Value)).ToArray());
                var s = String.Format(xmlStr, action, new Uri(url).GetLeftPart(UriPartial.Authority) + "/", parms);
                soapEnvelopeXml.LoadXml(s);
    
                // Create the web request
                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
                webRequest.Headers.Add("SOAPAction", soapAction ?? url);
                webRequest.ContentType = (useSOAP12) ? "application/soap+xml;charset=\"utf-8\"" : "text/xml;charset=\"utf-8\"";
                webRequest.Accept = (useSOAP12) ? "application/soap+xml" : "text/xml";
                webRequest.Method = "POST";
    
                // Insert SOAP envelope
                using (Stream stream = webRequest.GetRequestStream())
                {
                    soapEnvelopeXml.Save(stream);
                }
    
                // Send request and retrieve result
                string result;
                using (WebResponse response = webRequest.GetResponse())
                {
                    using (StreamReader rd = new StreamReader(response.GetResponseStream()))
                    {
                        result = rd.ReadToEnd();
                    }
                }
                return result;
            }
        }

    SOAP data  (actual) what i receive after calling the service : 

    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <soapenv:Body>
      <ns1:processResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="https://www.hcsprovider.com/">
       <processReturn href="#id0"/>
      </ns1:processResponse>
      <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:TCBalanceInquiryResponse" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="urn:BeanService">
       <cardNumber xsi:type="xsd:string">5327970100637437</cardNumber>
       <employerID xsi:type="xsd:string"></employerID>
       <members href="#id1"/>
       <organizationNumber xsi:type="xsd:string">T40</organizationNumber>
       <purseNumber xsi:type="xsd:string">10630560</purseNumber>
       <purseType xsi:type="xsd:string">ALL</purseType>
       <responseCode xsi:type="xsd:string"></responseCode>
       <responseMessage xsi:type="xsd:string"></responseMessage>
       <resultArtifacts xsi:type="soapenc:Array" soapenc:arrayType="xsd:string[4]" xmlns:ns3="http://www.w3.org/2002/12/soap-encoding">
        <item>[TCBalanceInquiryDto][authorizedBalance]$         .00[/authorizedBalance][description][/description][ledgerBalance]$       20.00[/ledgerBalance][purseNumber]10630560[/purseNumber][purseType]PRK[/purseType][status]AVAILABLE[/status][/TCBalanceInquiryDto]</item>
        <item>[TCBalanceInquiryDto][authorizedBalance]$         .00[/authorizedBalance][description][/description][ledgerBalance][/ledgerBalance][purseNumber]10630560[/purseNumber][purseType]PTX[/purseType][status]NOT FOUND[/status][/TCBalanceInquiryDto]</item>
        <item>[TCBalanceInquiryDto][authorizedBalance]$         .00[/authorizedBalance][description][/description][ledgerBalance][/ledgerBalance][purseNumber]10630560[/purseNumber][purseType]TRN[/purseType][status]NOT FOUND[/status][/TCBalanceInquiryDto]</item>
        <item>[TCBalanceInquiryDto][authorizedBalance]$         .00[/authorizedBalance][description][/description][ledgerBalance][/ledgerBalance][purseNumber]10630560[/purseNumber][purseType]TTX[/purseType][status]NOT FOUND[/status][/TCBalanceInquiryDto]</item>
       </resultArtifacts>
       <soapFault xsi:type="xsd:string"></soapFault>
      </multiRef>
      <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:Array" soapenc:arrayType="xsd:anyType[4]" xmlns:ns4="http://www.w3.org/2002/12/soap-encoding" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
       <item href="#id2"/>
       <item href="#id3"/>
       <item href="#id4"/>
       <item href="#id5"/>
      </multiRef>
      <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns5:TCBalanceInquiryDto" xmlns:ns5="urn:BeanService" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
       <authorizedBalance xsi:type="xsd:string">$         .00</authorizedBalance>
       <description xsi:type="xsd:string"></description>
       <ledgerBalance xsi:type="xsd:string">$       20.00</ledgerBalance>
       <purseNumber xsi:type="xsd:string">10630560</purseNumber>
       <purseType xsi:type="xsd:string">PRK</purseType>
       <status xsi:type="xsd:string">AVAILABLE</status>
      </multiRef>
      <multiRef id="id4" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns6:TCBalanceInquiryDto" xmlns:ns6="urn:BeanService" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
       <authorizedBalance xsi:type="xsd:string">$         .00</authorizedBalance>
       <description xsi:type="xsd:string"></description>
       <ledgerBalance xsi:type="xsd:string"></ledgerBalance>
       <purseNumber xsi:type="xsd:string">10630560</purseNumber>
       <purseType xsi:type="xsd:string">TRN</purseType>
       <status xsi:type="xsd:string">NOT FOUND</status>
      </multiRef>
      <multiRef id="id3" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns7:TCBalanceInquiryDto" xmlns:ns7="urn:BeanService" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
       <authorizedBalance xsi:type="xsd:string">$         .00</authorizedBalance>
       <description xsi:type="xsd:string"></description>
       <ledgerBalance xsi:type="xsd:string"></ledgerBalance>
       <purseNumber xsi:type="xsd:string">10630560</purseNumber>
       <purseType xsi:type="xsd:string">PTX</purseType>
       <status xsi:type="xsd:string">NOT FOUND</status>
      </multiRef>
      <multiRef id="id5" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns8:TCBalanceInquiryDto" xmlns:ns8="urn:BeanService" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
       <authorizedBalance xsi:type="xsd:string">$         .00</authorizedBalance>
       <description xsi:type="xsd:string"></description>
       <ledgerBalance xsi:type="xsd:string"></ledgerBalance>
       <purseNumber xsi:type="xsd:string">10630560</purseNumber>
       <purseType xsi:type="xsd:string">TTX</purseType>
       <status xsi:type="xsd:string">NOT FOUND</status>
      </multiRef>
     </soapenv:Body>
    </soapenv:Envelope>

    i copied this xml response and created a class and pasted as special "PasteXMLasClasses" feature of VS IDE. Below the code after i did that.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace Service
    {
    
        // NOTE: Generated code may require at least .NET Framework 4.5 or .NET Core/Standard 2.0.
        /// <remarks/>
        [System.SerializableAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
        [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.xmlsoap.org/soap/envelope/", IsNullable = false)]
        public partial class Envelope
        {
    
            private EnvelopeBody bodyField;
    
            /// <remarks/>
            public EnvelopeBody Body
            {
                get
                {
                    return this.bodyField;
                }
                set
                {
                    this.bodyField = value;
                }
            }
        }
    
        /// <remarks/>
        [System.SerializableAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
        public partial class EnvelopeBody
        {
    
            private processResponse processResponseField;
    
            private multiRef[] multiRefField;
    
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Namespace = "https://www.hcsprovider.com/")]
            public processResponse processResponse
            {
                get
                {
                    return this.processResponseField;
                }
                set
                {
                    this.processResponseField = value;
                }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute("multiRef", Namespace = "")]
            public multiRef[] multiRef
            {
                get
                {
                    return this.multiRefField;
                }
                set
                {
                    this.multiRefField = value;
                }
            }
        }
    
        /// <remarks/>
        [System.SerializableAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "https://www.hcsprovider.com/")]
        [System.Xml.Serialization.XmlRootAttribute(Namespace = "https://www.hcsprovider.com/", IsNullable = false)]
        public partial class processResponse
        {
    
            private processReturn processReturnField;
    
            private string encodingStyleField;
    
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Namespace = "")]
            public processReturn processReturn
            {
                get
                {
                    return this.processReturnField;
                }
                set
                {
                    this.processReturnField = value;
                }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlAttributeAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
            public string encodingStyle
            {
                get
                {
                    return this.encodingStyleField;
                }
                set
                {
                    this.encodingStyleField = value;
                }
            }
        }
    
        /// <remarks/>
        [System.SerializableAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
        [System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
        public partial class processReturn
        {
    
            private string hrefField;
    
            /// <remarks/>
            [System.Xml.Serialization.XmlAttributeAttribute()]
            public string href
            {
                get
                {
                    return this.hrefField;
                }
                set
                {
                    this.hrefField = value;
                }
            }
        }
    
        /// <remarks/>
        [System.SerializableAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
        [System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
        public partial class multiRef
        {
    
            private string authorizedBalanceField;
    
            private object descriptionField;
    
            private string ledgerBalanceField;
    
            private multiRefItem[] itemField;
    
            private ulong cardNumberField;
    
            private bool cardNumberFieldSpecified;
    
            private object employerIDField;
    
            private multiRefMembers membersField;
    
            private string organizationNumberField;
    
            private uint purseNumberField;
    
            private bool purseNumberFieldSpecified;
    
            private string purseTypeField;
    
            private string statusField;
    
            private object responseCodeField;
    
            private object responseMessageField;
    
            private multiRefResultArtifacts resultArtifactsField;
    
            private object soapFaultField;
    
            private string idField;
    
            private byte rootField;
    
            private string encodingStyleField;
    
            private string arrayTypeField;
    
            /// <remarks/>
            public string authorizedBalance
            {
                get
                {
                    return this.authorizedBalanceField;
                }
                set
                {
                    this.authorizedBalanceField = value;
                }
            }
    
            /// <remarks/>
            public object description
            {
                get
                {
                    return this.descriptionField;
                }
                set
                {
                    this.descriptionField = value;
                }
            }
    
            /// <remarks/>
            public string ledgerBalance
            {
                get
                {
                    return this.ledgerBalanceField;
                }
                set
                {
                    this.ledgerBalanceField = value;
                }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute("item")]
            public multiRefItem[] item
            {
                get
                {
                    return this.itemField;
                }
                set
                {
                    this.itemField = value;
                }
            }
    
            /// <remarks/>
            public ulong cardNumber
            {
                get
                {
                    return this.cardNumberField;
                }
                set
                {
                    this.cardNumberField = value;
                }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlIgnoreAttribute()]
            public bool cardNumberSpecified
            {
                get
                {
                    return this.cardNumberFieldSpecified;
                }
                set
                {
                    this.cardNumberFieldSpecified = value;
                }
            }
    
            /// <remarks/>
            public object employerID
            {
                get
                {
                    return this.employerIDField;
                }
                set
                {
                    this.employerIDField = value;
                }
            }
    
            /// <remarks/>
            public multiRefMembers members
            {
                get
                {
                    return this.membersField;
                }
                set
                {
                    this.membersField = value;
                }
            }
    
            /// <remarks/>
            public string organizationNumber
            {
                get
                {
                    return this.organizationNumberField;
                }
                set
                {
                    this.organizationNumberField = value;
                }
            }
    
            /// <remarks/>
            public uint purseNumber
            {
                get
                {
                    return this.purseNumberField;
                }
                set
                {
                    this.purseNumberField = value;
                }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlIgnoreAttribute()]
            public bool purseNumberSpecified
            {
                get
                {
                    return this.purseNumberFieldSpecified;
                }
                set
                {
                    this.purseNumberFieldSpecified = value;
                }
            }
    
            /// <remarks/>
            public string purseType
            {
                get
                {
                    return this.purseTypeField;
                }
                set
                {
                    this.purseTypeField = value;
                }
            }
    
            /// <remarks/>
            public string status
            {
                get
                {
                    return this.statusField;
                }
                set
                {
                    this.statusField = value;
                }
            }
    
            /// <remarks/>
            public object responseCode
            {
                get
                {
                    return this.responseCodeField;
                }
                set
                {
                    this.responseCodeField = value;
                }
            }
    
            /// <remarks/>
            public object responseMessage
            {
                get
                {
                    return this.responseMessageField;
                }
                set
                {
                    this.responseMessageField = value;
                }
            }
    
            /// <remarks/>
            public multiRefResultArtifacts resultArtifacts
            {
                get
                {
                    return this.resultArtifactsField;
                }
                set
                {
                    this.resultArtifactsField = value;
                }
            }
    
            /// <remarks/>
            public object soapFault
            {
                get
                {
                    return this.soapFaultField;
                }
                set
                {
                    this.soapFaultField = value;
                }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlAttributeAttribute()]
            public string id
            {
                get
                {
                    return this.idField;
                }
                set
                {
                    this.idField = value;
                }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlAttributeAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.xmlsoap.org/soap/encoding/")]
            public byte root
            {
                get
                {
                    return this.rootField;
                }
                set
                {
                    this.rootField = value;
                }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlAttributeAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
            public string encodingStyle
            {
                get
                {
                    return this.encodingStyleField;
                }
                set
                {
                    this.encodingStyleField = value;
                }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlAttributeAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.xmlsoap.org/soap/encoding/")]
            public string arrayType
            {
                get
                {
                    return this.arrayTypeField;
                }
                set
                {
                    this.arrayTypeField = value;
                }
            }
        }
    
        /// <remarks/>
        [System.SerializableAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
        public partial class multiRefItem
        {
    
            private string hrefField;
    
            /// <remarks/>
            [System.Xml.Serialization.XmlAttributeAttribute()]
            public string href
            {
                get
                {
                    return this.hrefField;
                }
                set
                {
                    this.hrefField = value;
                }
            }
        }
    
        /// <remarks/>
        [System.SerializableAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
        public partial class multiRefMembers
        {
    
            private string hrefField;
    
            /// <remarks/>
            [System.Xml.Serialization.XmlAttributeAttribute()]
            public string href
            {
                get
                {
                    return this.hrefField;
                }
                set
                {
                    this.hrefField = value;
                }
            }
        }
    
        /// <remarks/>
        [System.SerializableAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
        public partial class multiRefResultArtifacts
        {
    
            private string[] itemField;
    
            private string arrayTypeField;
    
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute("item")]
            public string[] item
            {
                get
                {
                    return this.itemField;
                }
                set
                {
                    this.itemField = value;
                }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlAttributeAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.xmlsoap.org/soap/encoding/")]
            public string arrayType
            {
                get
                {
                    return this.arrayTypeField;
                }
                set
                {
                    this.arrayTypeField = value;
                }
            }
        }
    }

    Finally, i am trying to deserialize as below:

    var str = SOAPHelper.SendSOAPRequest(URL, "process", parameters);
    var rawXML = XDocument.Parse(str);
                    Service.Envelope deserializedObject;
                    using (var reader = rawXML.CreateReader(System.Xml.Linq.ReaderOptions.None))
                    {
                        var ser = new XmlSerializer(typeof(Service.Envelope));
                        deserializedObject = (Service.Envelope)ser.Deserialize(reader);
                    }

    When i run the applicatiion, am getting error as below

    {"There is an error in XML document (0, 0)."}

    I am not sure where the error is coming from. please help me solve this issue. i spent lot of time to see whats wrong in the xml string. my bad, i couldn't find it. any help will be highly appreciated. 

    Thank you.

    Monday, November 18, 2019 9:11 PM

Answers

  • User288213138 posted

    Hi born2win,

    born2win

    {"There is an error in XML document (0, 0)."}

    born2win

    <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:TCBalanceInquiryResponse" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="urn:BeanService">

    I try to Deserialize your xml file, and get the error in the "name='TCBalanceInquiryResponse', namespace='urn:BeanService', at <multiRef xmlns=''>". 

    You can try to modify it according to your requirement.

    Best regards,

    Sam

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 19, 2019 10:13 AM
  • User475983607 posted

    This url is not created by us. its from our client and they developed using JAVA. its not ASMX or WCF. i dont have WSDL file from client. i have  to work without proxy. Any  suggestions please

    You misunderstand.  ASMX and WCF are ASP.NET SOAP client and server libraries.  The XML shown above is a SOAP message regardless of the language used to create the service.  WSDL (Web Service Description Language) is a standard in SOAP.  Clients cannot interact with a SOAP service without knowing the service description.  The only reason a SOAP service would not expose the WSDL is because the client does not have permission to use the service.  

    Keep in mind it's impossible or at least it will take a lot of trial and error to gleam the service definition from a SOAP messages.  It's like learning to baking a cake without the recipe and using an existing cake as the template. 

    Contact the client and ask for the WSDL.  At the very least they should have the XSDs.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 19, 2019 4:59 PM

All replies

  • User475983607 posted

    It's a lot easier to create a service reference using the WSDL.

    Monday, November 18, 2019 9:38 PM
  • User1489758560 posted

    i would need to achieve using without creating proxy. please help me in this.

    Tuesday, November 19, 2019 3:13 AM
  • User288213138 posted

    Hi born2win,

    born2win

    {"There is an error in XML document (0, 0)."}

    born2win

    <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:TCBalanceInquiryResponse" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="urn:BeanService">

    I try to Deserialize your xml file, and get the error in the "name='TCBalanceInquiryResponse', namespace='urn:BeanService', at <multiRef xmlns=''>". 

    You can try to modify it according to your requirement.

    Best regards,

    Sam

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 19, 2019 10:13 AM
  • User475983607 posted

    i would need to achieve using without creating proxy. please help me in this.

    Ironically, you are writing a proxy.  A very poor implementation but a proxy nonetheless.  The rest of the world using the WSDL.  Can you explain why you have this requirement? Is this an educational project?

    A code generated proxy is not needed if you have the source code; data contracts and service interfaces.  From there you can write code to communicate with the service endpoint using the standard WCF library.  A  proxy is nothing more than a local copy of the interfaces and types from the remote host. Generally the remote host does not share the source code and exposes the contract in the WSDL.  This is a standard.   If you wrote the service code then simply use the ServiceHost to open a connection and invoke the service contracts. 

    Please see the WCF documentation which covers how to do this.

    https://docs.microsoft.com/en-us/dotnet/framework/wcf/how-to-specify-a-service-binding-in-code

    Tuesday, November 19, 2019 1:01 PM
  • User1489758560 posted

    Hi,

    This url is not created by us. its from our client and they developed using JAVA. its not ASMX or WCF. i dont have WSDL file from client. i have  to work without proxy. Any  suggestions please

    Tuesday, November 19, 2019 4:46 PM
  • User475983607 posted

    This url is not created by us. its from our client and they developed using JAVA. its not ASMX or WCF. i dont have WSDL file from client. i have  to work without proxy. Any  suggestions please

    You misunderstand.  ASMX and WCF are ASP.NET SOAP client and server libraries.  The XML shown above is a SOAP message regardless of the language used to create the service.  WSDL (Web Service Description Language) is a standard in SOAP.  Clients cannot interact with a SOAP service without knowing the service description.  The only reason a SOAP service would not expose the WSDL is because the client does not have permission to use the service.  

    Keep in mind it's impossible or at least it will take a lot of trial and error to gleam the service definition from a SOAP messages.  It's like learning to baking a cake without the recipe and using an existing cake as the template. 

    Contact the client and ask for the WSDL.  At the very least they should have the XSDs.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 19, 2019 4:59 PM
  • User1489758560 posted

    thank you for the reply . appreciated.

    Wednesday, November 20, 2019 7:12 PM