Why is the result different from web service links and service links?

I'm a little curious as to what happened, trying to understand the concept of a service reference and links to the Web service .

What I've done?

In my project, I have added web service

as a Service Reference and will try to run my script through using the client. But when getting the result, it throws an exception like in the following image:

Exception while running the script

I tried to trace the cause but couldn't get the correct answer. I have the following code for the resulting object.

[
        ComVisible(false), 
        Serializable,
        SoapTypeAttribute("RecordList", "http://www.someadd.com/dev/ns/SOF/2.0"),       
        XmlType(TypeName="RecordList", Namespace="http://www.someadd.com/dev/ns/SOF/2.0")       
    ]
    public class MyRecordListWrapper
    {
        private IxRecordList recordList = null;
        private const string XMLW3CSchema = "http://www.w3.org/2001/XMLSchema";

        [SoapElement("Headers")]
        public Header[] Headers = null;
        [SoapElement("Records")]
        public Record[] Records = null;
        // some methods to work on intialization
        public SmRecordListWrapper(ref IxRecordList p_RecordList)
        {
            recordList = p_RecordList;// record list initialization             
            Headers = CreateWrapperHeaders(); // will return header class object
            Records = CreateWrapperRecords(); // will return record object
        }   
    }

      

Can anyone tell me why this error is showing up for me?

When adding a link as a web service reference, when do I add the same link as web reference

in so that the program does not show any errors and runs successfully?

So can anyone tell me what is the difference in working with the same code using a service link and a web service link? and what is the correct way to link to links?

Hope I get some more detailed answers to make things easy to understand.

Thanks in advance.

+3


source to share


1 answer


Adding a web link, visual studio uses xsd.exe to generate classes from service metadata. This is using the XmlSerializer under the hood.

Adding a service reference, visual studio uses svcutil.exe to generate classes from metadata. This is using the DataContractSerializer under the hood.



Two separate tools, two results. For general information, the DataContractSerializer is much less forgiving when it comes to generating classes from metadata.

+1


source







All Articles