0

UPDATE: I have WSDL file from SAP web service which is Imported as Connected Services in Visual Studio code, as below:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace SAPWebService
{
          [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
    [System.ServiceModel.ServiceContractAttribute(Namespace="urn:sap-com:document:sap:rfc:functions", ConfigurationName="ServiceReference1.ZMM_SIF_KARAKTERISTIKE_MAT")]
    public interface ZMM_SIF_KARAKTERISTIKE_MAT
    {
        
        [System.ServiceModel.OperationContractAttribute(Action="urn:sap-com:document:sap:rfc:functions:ZMM_SIF_KARAKTERISTIKE_MAT:ZMM_SIF_KARAKTE" +
            "RISTIKE_MATRequest", ReplyAction="urn:sap-com:document:sap:rfc:functions:ZMM_SIF_KARAKTERISTIKE_MAT:ZMM_SIF_KARAKTE" +
            "RISTIKE_MATResponse")]
        [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
        System.Threading.Tasks.Task<SAPWebService.ZMM_SIF_KARAKTERISTIKE_MATResponse1> ZMM_SIF_KARAKTERISTIKE_MATAsync(SAPWebService.ZMM_SIF_KARAKTERISTIKE_MATRequest request);
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:sap-com:document:sap:rfc:functions")]
    public partial class ZMM_SIF_KARAKTERISTIKE_MAT1
    {
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:sap-com:document:sap:rfc:functions")]
    public partial class ZMM_KARAKTERISTIKE_MAT_LINE
    {
        
        private string kLASAField;
        
        private string kARAKTERISTIKAField;
        
        private string vREDNOSTField;
        
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
        public string KLASA
        {
            get
            {
                return this.kLASAField;
            }
            set
            {
                this.kLASAField = value;
            }
        }
        
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)]
        public string KARAKTERISTIKA
        {
            get
            {
                return this.kARAKTERISTIKAField;
            }
            set
            {
                this.kARAKTERISTIKAField = value;
            }
        }
        
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)]
        public string VREDNOST
        {
            get
            {
                return this.vREDNOSTField;
            }
            set
            {
                this.vREDNOSTField = value;
            }
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:sap-com:document:sap:rfc:functions")]
    public partial class ZMM_SIF_KARAKTERISTIKE_MATResponse
    {
        
        private ZMM_KARAKTERISTIKE_MAT_LINE[] kARAKTERISTIKAField;
        
        /// <remarks/>
        [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
        [System.Xml.Serialization.XmlArrayItemAttribute("item", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
        public ZMM_KARAKTERISTIKE_MAT_LINE[] KARAKTERISTIKA
        {
            get
            {
                return this.kARAKTERISTIKAField;
            }
            set
            {
                this.kARAKTERISTIKAField = value;
            }
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    [System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
    public partial class ZMM_SIF_KARAKTERISTIKE_MATRequest
    {
        
        [System.ServiceModel.MessageBodyMemberAttribute(Namespace="urn:sap-com:document:sap:rfc:functions", Order=0)]
        public SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT ZMM_SIF_KARAKTERISTIKE_MAT;
        
        public ZMM_SIF_KARAKTERISTIKE_MATRequest()
        {
        }
        
        public ZMM_SIF_KARAKTERISTIKE_MATRequest(SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT ZMM_SIF_KARAKTERISTIKE_MAT)
        {
            this.ZMM_SIF_KARAKTERISTIKE_MAT = ZMM_SIF_KARAKTERISTIKE_MAT;
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    [System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
    public partial class ZMM_SIF_KARAKTERISTIKE_MATResponse1
    {
        
        [System.ServiceModel.MessageBodyMemberAttribute(Namespace="urn:sap-com:document:sap:rfc:functions", Order=0)]
        public SAPWebService.ZMM_SIF_KARAKTERISTIKE_MATResponse ZMM_SIF_KARAKTERISTIKE_MATResponse;
        
        public ZMM_SIF_KARAKTERISTIKE_MATResponse1()
        {
        }
        
        public ZMM_SIF_KARAKTERISTIKE_MATResponse1(SAPWebService.ZMM_SIF_KARAKTERISTIKE_MATResponse ZMM_SIF_KARAKTERISTIKE_MATResponse)
        {
            this.ZMM_SIF_KARAKTERISTIKE_MATResponse = ZMM_SIF_KARAKTERISTIKE_MATResponse;
        }
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
    public interface ZMM_SIF_KARAKTERISTIKE_MATChannel : SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT, System.ServiceModel.IClientChannel
    {
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
    public partial class ZMM_SIF_KARAKTERISTIKE_MATClient : System.ServiceModel.ClientBase<SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT>, SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT
    {
        
        public ZMM_SIF_KARAKTERISTIKE_MATClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(binding, remoteAddress)
        {
        }
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        System.Threading.Tasks.Task<SAPWebService.ZMM_SIF_KARAKTERISTIKE_MATResponse1> SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT.ZMM_SIF_KARAKTERISTIKE_MATAsync(SAPWebService.ZMM_SIF_KARAKTERISTIKE_MATRequest request)
        {
            return base.Channel.ZMM_SIF_KARAKTERISTIKE_MATAsync(request);
        }
        
        public System.Threading.Tasks.Task<SAPWebService.ZMM_SIF_KARAKTERISTIKE_MATResponse1> ZMM_SIF_KARAKTERISTIKE_MATAsync(SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT ZMM_SIF_KARAKTERISTIKE_MAT)
        {
            SAPWebService.ZMM_SIF_KARAKTERISTIKE_MATRequest inValue = new SAPWebService.ZMM_SIF_KARAKTERISTIKE_MATRequest();
            inValue.ZMM_SIF_KARAKTERISTIKE_MAT = ZMM_SIF_KARAKTERISTIKE_MAT;
            return ((SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT)(this)).ZMM_SIF_KARAKTERISTIKE_MATAsync(inValue);
        }
        
        public virtual System.Threading.Tasks.Task OpenAsync()
        {
            return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(null, null), new System.Action<System.IAsyncResult>(((System.ServiceModel.ICommunicationObject)(this)).EndOpen));
        }
        
        public virtual System.Threading.Tasks.Task CloseAsync()
        {
            return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginClose(null, null), new System.Action<System.IAsyncResult>(((System.ServiceModel.ICommunicationObject)(this)).EndClose));
        }
    }
}

IMPORTANT UPDATE:

When I added wsdl as connected service, I get this error:

Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:rfc:functions']/wsdl:binding[@name='250_soap12']
XPath to Error Source: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:rfc:functions']/wsdl:service[@name='ZMM_SIF_KARAKTERISTIKE_MAT']/wsdl:port[@name='250_soap12']
Cannot import wsdl:binding
Detail: Name cannot begin with the '2' character, hexadecimal value 0x32.
Parameter name: name
XPath to Error Source: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:rfc:functions']/wsdl:binding[@name='250_soap12']
Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:rfc:functions']/wsdl:binding[@name='250']
XPath to Error Source: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:rfc:functions']/wsdl:service[@name='ZMM_SIF_KARAKTERISTIKE_MAT']/wsdl:port[@name='250']
Cannot import wsdl:binding
Detail: Name cannot begin with the '2' character, hexadecimal value 0x32.
Parameter name: name
XPath to Error Source: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:rfc:functions']/wsdl:binding[@name='250']
The optional WSDL extension element 'Policy' from namespace 'http://schemas.xmlsoap.org/ws/2004/09/policy' was not handled.
XPath: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:rfc:functions']/wsdl:portType[@name='ZMM_SIF_KARAKTERISTIKE_MAT']/wsdl:operation[@name='ZMM_SIF_KARAKTERISTIKE_MAT']
The optional WSDL extension element 'Policy' from namespace 'http://schemas.xmlsoap.org/ws/2004/09/policy' was not handled.
XPath: //wsdl:definitions[@targetNamespace='urn:sap-com:document:sap:rfc:functions']/wsdl:portType[@name='ZMM_SIF_KARAKTERISTIKE_MAT']





    

And I tried to consume it from C# in method as below:

    public class SAPDemoApi : ISAPDemoApi
    {
        public readonly string serviceUrl = "http://GIRKV06S04.gir.local:8000/sap/bc/srt/rfc/sap/zmm_sif_karakteristike_mat/250/zmm_sif_karakteristike_mat/250";
        public readonly EndpointAddress endpointAddress;
        public readonly BasicHttpBinding basicHttpBinding;

        public SAPDemoApi()
        {
            endpointAddress = new EndpointAddress(serviceUrl);

            basicHttpBinding =
                new BasicHttpBinding(endpointAddress.Uri.Scheme.ToLower() == "http" ?
                            BasicHttpSecurityMode.None : BasicHttpSecurityMode.Transport);

            //Please set the time accordingly, this is only for demo
            basicHttpBinding.OpenTimeout = TimeSpan.MaxValue;
            basicHttpBinding.CloseTimeout = TimeSpan.MaxValue;
            basicHttpBinding.ReceiveTimeout = TimeSpan.MaxValue;
            basicHttpBinding.SendTimeout = TimeSpan.MaxValue;
        }

        public async Task<ZMM_SIF_KARAKTERISTIKE_MATResponse> GetData()
        {
            var client = await GetInstanceAsync();
            var response = await client.ZMM_SIF_KARAKTERISTIKE_MATAsync(new ZMM_SIF_KARAKTERISTIKE_MATClient(basicHttpBinding, endpointAddress));
            return response.ZMM_SIF_KARAKTERISTIKE_MATResponse;
        }


        public async Task<ZMM_SIF_KARAKTERISTIKE_MATClient> GetInstanceAsync()
        {
            return await Task.Run(() => new ZMM_SIF_KARAKTERISTIKE_MATClient(basicHttpBinding, endpointAddress));
        }
    }

Note: I have used http://GIRKV06S04.gir.local:8000/sap/bc/srt/rfc/sap/zmm_sif_karakteristike_mat/250/zmm_sif_karakteristike_mat/250 due to the url I got it from SoapUI when sent request to web service(previously I have imported WSDL file into SoapUI).

When I try to call it var output = await sapDemoApi.GetData(); I am getting an error: System.InvalidOperationException: There was an error reflecting 'ZMM_SIF_KARAKTERISTIKE_MAT'. ---> System.NotSupportedException: Cannot serialize interface SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT. at System.Xml.Serialization.TypeDesc.CheckSupported() at System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError)

UPDATE:

        <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
       <soap-env:Header/>
       <soap-env:Body>
          <n0:ZMM_SIF_KARAKTERISTIKE_MATResponse xmlns:n0="urn:sap-com:document:sap:rfc:functions">
             <KARAKTERISTIKA>
                <item>
                   <KLASA>Z_TRUPCI_MAT</KLASA>
                   <KARAKTERISTIKA>VRSTADRVETA</KARAKTERISTIKA>
                   <VREDNOST>0</VREDNOST>
                </item>
                <item>
                   <KLASA>Z_TRUPCI_MAT</KLASA>
                   <KARAKTERISTIKA>VRSTADRVETA</KARAKTERISTIKA>
                   <VREDNOST>1</VREDNOST>
                </item>
                <item>
                   <KLASA>Z_TRUPCI_MAT</KLASA>
                   <KARAKTERISTIKA>VRSTADRVETA</KARAKTERISTIKA>
                   <VREDNOST>2</VREDNOST>
                </item>
                <item>
                   <KLASA>Z_TRUPCI_MAT</KLASA>
                   <KARAKTERISTIKA>VRSTADRVETA</KARAKTERISTIKA>
                   <VREDNOST>26</VREDNOST>
                </item>
                <item>
                   <KLASA>Z_TRUPCI_MAT</KLASA>
                   <KARAKTERISTIKA>VRSTADRVETA</KARAKTERISTIKA>
                   <VREDNOST>27</VREDNOST>
                </item>
                <item>
                   <KLASA>Z_TRUPCI_MAT</KLASA>
                   <KARAKTERISTIKA>VRSTADRVETA</KARAKTERISTIKA>
                   <VREDNOST>28</VREDNOST>
                </item>
                <item>
                   <KLASA>Z_TRUPCI_MAT</KLASA>
                   <KARAKTERISTIKA>VRSTADRVETA</KARAKTERISTIKA>
                   <VREDNOST>29</VREDNOST>
                </item>
                <item>
                   <KLASA>Z_TRUPCI_MAT</KLASA>
                   <KARAKTERISTIKA>VRSTADRVETA</KARAKTERISTIKA>
                   <VREDNOST>30</VREDNOST>
                </item>
                <item>
                   <KLASA>Z_TRUPCI_MAT</KLASA>
                   <KARAKTERISTIKA>VRSTADRVETA</KARAKTERISTIKA>
                   <VREDNOST>31</VREDNOST>
                </item>
                <item>
                   <KLASA>Z_TRUPCI_MAT</KLASA>
                   <KARAKTERISTIKA>VRSTADRVETA</KARAKTERISTIKA>
                   <VREDNOST>32</VREDNOST>
                </item>
                <item>
                   <KLASA>Z_GRADJA_MAT</KLASA>
                   <KARAKTERISTIKA>TIPDRVETA</KARAKTERISTIKA>
                   <VREDNOST>O</VREDNOST>
                </item>
                <item>
                   <KLASA>Z_GRADJA_MAT</KLASA>
                   <KARAKTERISTIKA>TIPDRVETA</KARAKTERISTIKA>
                   <VREDNOST>N</VREDNOST>
                </item>
             </KARAKTERISTIKA>
          </n0:ZMM_SIF_KARAKTERISTIKE_MATResponse>
       </soap-env:Body>
    </soap-env:Envelope>
projo9494
  • 67
  • 6
  • The xml is not matching the schema. Can't tell without seeing the xml response. The schema was by the tool to generate the c# classes. The WSDL has extra tags that are not in the xml. So normally you have to move get the first tag of the xml and the class from the WSDL to be the same. – jdweng Dec 30 '20 at 13:27
  • I have updated question with response. So, what should I need to replace? – projo9494 Dec 30 '20 at 13:41
  • You response xml starts with a Envelope but the c# starts with the tag ZMM_SIF_KARAKTERISTIKE_MATResponse. See : https://learn.microsoft.com/en-us/previous-versions/dotnet/netframework-3.0/bb559021(v=vs.85)?redirectedfrom=MSDN – jdweng Dec 30 '20 at 13:54
  • Sorry, but I don't understand what I should and where to fix. In an example you send me, is is logical to get ZMM_SIF_KARAKTERISTIKE_MATResponse, because I am sending ZMM_SIF_KARAKTERISTIKE_MAT in Body. Where exactly I need to replace and what? – projo9494 Dec 30 '20 at 14:20
  • Use ResonseElementName as in this example : https://learn.microsoft.com/en-us/dotnet/api/system.web.services.protocols.soapdocumentmethodattribute?redirectedfrom=MSDN&view=netframework-4.8. The other choice is to add you own two c# classes for Envelope and Body. – jdweng Dec 30 '20 at 15:19
  • @jdweng Please check the whole question again. I was mixed other wsdl file, I am sorry. Now I have updated the whole question and the code. Review question again. I am getting the same error. – projo9494 Jan 11 '21 at 08:33
  • Did you see following : "Detail: Name cannot begin with the '2' character, hexadecimal value 0x32." The character 0x32 is the digit 2. – jdweng Jan 12 '21 at 11:38
  • I think it is the problem with wsdl. This is the part related to binding from wsdl ****. Name is 250, so it starts with 2. – projo9494 Jan 12 '21 at 12:37
  • You have to bind to a variable and in c# variables do not start with digits. – jdweng Jan 12 '21 at 12:41
  • To which variable and how? – projo9494 Jan 12 '21 at 13:27
  • Where did you get the 250? – jdweng Jan 12 '21 at 13:58
  • It is inside wsdl file I got from external SAP consultants. So, when I open wsdl file and search from wsdl:binding I get the part of xml code above. – projo9494 Jan 12 '21 at 14:18
  • Ask the consultant. It just may be a placeholder for a real variable name. – jdweng Jan 12 '21 at 14:20
  • Is it good approach to avoid wsdl file, and directly send request to specified url and body of request, like in SOAP UI? Check in this [link](https://www.roelvanlisdonk.nl/2011/01/28/how-to-call-a-soap-web-service-in-net-4-0-c-without-using-the-wsdl-or-proxy-classes/) – projo9494 Jan 13 '21 at 06:45

1 Answers1

0

I added an Envelope and Body to your classes to get the code to work. I used Xml Serialize to test the code and commented out what wasn't needed to deserialize the object. You need to modify your code to do similar to what I've done

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
namespace ConsoleApplication177
{
    class Program
    {
        const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            string xml = File.ReadAllText(FILENAME);
            StringReader sReader = new StringReader(xml);
            XmlReader xReader = XmlReader.Create(sReader);
            XmlSerializer serializer = new XmlSerializer(typeof(Envelope));
            Envelope envelope = (Envelope)serializer.Deserialize(xReader);

        }
    }
    [XmlRoot(ElementName = "Envelope" ,Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
    public class Envelope
    {
        [XmlElement(Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
        public Body Body { get; set; }
    }

    public class Body
    {
        [XmlElement(ElementName = "ZMM_SIF_KARAKTERISTIKE_MATResponse", Namespace = "urn:sap-com:document:sap:rfc:functions")]
        public ZMM_SIF_KARAKTERISTIKE_MATResponse ZMM_SIF_KARAKTERISTIKE_MATResponse { get; set; }
    }

    ///// <remarks/>
    //[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
    //[System.Diagnostics.DebuggerStepThroughAttribute()]
    //[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "urn:sap-com:document:sap:rfc:functions")]
    //public partial class ZMM_SIF_KARAKTERISTIKE_MAT1
    //{
    //}

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace = "urn:sap-com:document:sap:rfc:functions")]
    public partial class ZMM_KARAKTERISTIKE_MAT_LINE
    {

        private string kLASAField;

        private string kARAKTERISTIKAField;

        private string vREDNOSTField;

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

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

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 2)]
        public string VREDNOST
        {
            get
            {
                return this.vREDNOSTField;
            }
            set
            {
                this.vREDNOSTField = value;
            }
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "urn:sap-com:document:sap:rfc:functions")]
    public class ZMM_SIF_KARAKTERISTIKE_MATResponse
    {

        private ZMM_KARAKTERISTIKE_MAT_LINE[] kARAKTERISTIKAField;

        /// <remarks/>
        [System.Xml.Serialization.XmlArrayAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 0)]
        [System.Xml.Serialization.XmlArrayItemAttribute("item", Form = System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable = false)]
        public ZMM_KARAKTERISTIKE_MAT_LINE[] KARAKTERISTIKA
        {
            get
            {
                return this.kARAKTERISTIKAField;
            }
            set
            {
                this.kARAKTERISTIKAField = value;
            }
        }
    }

    //[System.Diagnostics.DebuggerStepThroughAttribute()]
    //[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
    //[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    //[System.ServiceModel.MessageContractAttribute(IsWrapped = false)]
    //public partial class ZMM_SIF_KARAKTERISTIKE_MATRequest
    //{

    //    [System.ServiceModel.MessageBodyMemberAttribute(Namespace = "urn:sap-com:document:sap:rfc:functions", Order = 0)]
    //    public SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT ZMM_SIF_KARAKTERISTIKE_MAT;

    //    public ZMM_SIF_KARAKTERISTIKE_MATRequest()
    //    {
    //    }

    //    public ZMM_SIF_KARAKTERISTIKE_MATRequest(SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT ZMM_SIF_KARAKTERISTIKE_MAT)
    //    {
    //        this.ZMM_SIF_KARAKTERISTIKE_MAT = ZMM_SIF_KARAKTERISTIKE_MAT;
    //    }
    //}

    //[System.Diagnostics.DebuggerStepThroughAttribute()]
    //[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
    //[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    //[System.ServiceModel.MessageContractAttribute(IsWrapped = false)]
    //public partial class ZMM_SIF_KARAKTERISTIKE_MATResponse1
    //{

    //    [System.ServiceModel.MessageBodyMemberAttribute(Namespace = "urn:sap-com:document:sap:rfc:functions", Order = 0)]
    //    public SAPWebService.ZMM_SIF_KARAKTERISTIKE_MATResponse ZMM_SIF_KARAKTERISTIKE_MATResponse;

    //    public ZMM_SIF_KARAKTERISTIKE_MATResponse1()
    //    {
    //    }

    //    public ZMM_SIF_KARAKTERISTIKE_MATResponse1(SAPWebService.ZMM_SIF_KARAKTERISTIKE_MATResponse ZMM_SIF_KARAKTERISTIKE_MATResponse)
    //    {
    //        this.ZMM_SIF_KARAKTERISTIKE_MATResponse = ZMM_SIF_KARAKTERISTIKE_MATResponse;
    //    }
    //}

    //[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
    //public interface ZMM_SIF_KARAKTERISTIKE_MATChannel : SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT, System.ServiceModel.IClientChannel
    //{
    //}

    //[System.Diagnostics.DebuggerStepThroughAttribute()]
    //[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
    //public partial class ZMM_SIF_KARAKTERISTIKE_MATClient : System.ServiceModel.ClientBase<SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT>, SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT
    //{

    //    public ZMM_SIF_KARAKTERISTIKE_MATClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
    //        base(binding, remoteAddress)
    //    {
    //    }

    //    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    //    System.Threading.Tasks.Task<SAPWebService.ZMM_SIF_KARAKTERISTIKE_MATResponse1> SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT.ZMM_SIF_KARAKTERISTIKE_MATAsync(SAPWebService.ZMM_SIF_KARAKTERISTIKE_MATRequest request)
    //    {
    //        return base.Channel.ZMM_SIF_KARAKTERISTIKE_MATAsync(request);
    //    }

    //    public System.Threading.Tasks.Task<SAPWebService.ZMM_SIF_KARAKTERISTIKE_MATResponse1> ZMM_SIF_KARAKTERISTIKE_MATAsync(SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT ZMM_SIF_KARAKTERISTIKE_MAT)
    //    {
    //        SAPWebService.ZMM_SIF_KARAKTERISTIKE_MATRequest inValue = new SAPWebService.ZMM_SIF_KARAKTERISTIKE_MATRequest();
    //        inValue.ZMM_SIF_KARAKTERISTIKE_MAT = ZMM_SIF_KARAKTERISTIKE_MAT;
    //        return ((SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT)(this)).ZMM_SIF_KARAKTERISTIKE_MATAsync(inValue);
    //    }

    //    public virtual System.Threading.Tasks.Task OpenAsync()
    //    {
    //        return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(null, null), new System.Action<System.IAsyncResult>(((System.ServiceModel.ICommunicationObject)(this)).EndOpen));
    //    }

    //    public virtual System.Threading.Tasks.Task CloseAsync()
    //    {
    //        return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginClose(null, null), new System.Action<System.IAsyncResult>(((System.ServiceModel.ICommunicationObject)(this)).EndClose));
    //    }
    //}
   
}
jdweng
  • 33,250
  • 2
  • 15
  • 20
  • What have you put inside c:\temp\test.xml? How to send request to web service to get data(should I also send request using Envelope and Body, but specified for Request only)? – projo9494 Jan 11 '21 at 13:02
  • I put the your xml in to the file which includes the Envelope and Body. You should keep the request the same as you current request with no changes. – jdweng Jan 11 '21 at 13:36
  • **GetData** in class **SAPDemoApi** is responsible for sending request to SOAP web service, but it has the error Cannot serialize interface SAPWebService.ZMM_SIF_KARAKTERISTIKE_MAT... – projo9494 Jan 11 '21 at 13:56
  • Don't you have to change GetData From : ZMM_SIF_KARAKTERISTIKE_MATResponse to Envelope? – jdweng Jan 11 '21 at 14:03
  • These two lines of code are in that method. var client = await GetInstanceAsync(); var response = await client.ZMM_SIF_KARAKTERISTIKE_MATAsync(new ZMM_SIF_KARAKTERISTIKE_MATClient(basicHttpBinding, endpointAddress)); How to change it, assuming that client.ZMM_SIF_KARAKTERISTIKE_MATAsync returning ZMM_SIF_KARAKTERISTIKE_MATResponse? – projo9494 Jan 12 '21 at 06:44
  • Also check the Important Update.. I was missing the fact I had an error while importing wsdl file in visual studio. – projo9494 Jan 12 '21 at 08:29