[英]Why the result from the web service references and Service references are different?
I am bit curious about one thing which has happen while trying to understand the concept of Service References and Web Service References . 我对尝试理解服务引用和Web服务引用的概念时发生的一件事感到有点好奇。
What I did is? 我做的是什么?
In my project I have added a web service
as a Service Reference and trying to get my script run through the use of client. 在我的项目中,我添加了一个
web service
作为服务引用,并尝试通过使用客户端来运行我的脚本。 But while getting result it is throwing an exception as in the following image: 但是在获得结果时,它会抛出异常,如下图所示:
I have tried to trace out the cause but not able to get the proper answer for that. 我试图找出原因,但无法得到正确答案。 I have following code for the resultant 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 for me? 任何人都可以告诉我为什么这个错误对我来说?
While adding reference as a Web Service Reference when I add the same reference as a web reference
that time the program is not showing any error and runs successfully? 在我添加与
web reference
相同的引用时添加引用作为Web服务 web reference
,那时程序没有显示任何错误并成功运行?
So can anyone tell me what is the difference in working with the same code using service reference and web service reference? 那么有谁能告诉我使用服务引用和Web服务引用使用相同的代码有什么区别? and Which is a correct way to ass references?
哪个是正确的引用方式?
Hope I will get some more described answers to make the things easy to understand. 希望我能得到更多描述的答案,使事情易于理解。
Thanks in advance. 提前致谢。
Adding a web reference, visual studio uses xsd.exe to generate the classes from the service metadata. 添加Web引用,visual studio使用xsd.exe从服务元数据生成类。 This uses XmlSerializer under the hood.
这使用了引擎盖下的XmlSerializer。
Adding a service reference, visual studio uses svcutil.exe to generate the classes from the metadata. 添加服务引用,visual studio使用svcutil.exe从元数据生成类。 This uses DataContractSerializer under the hood.
这使用了引擎盖下的DataContractSerializer。
Two separate tools, two outcomes. 两个独立的工具,两个结果。 For general information, DataContractSerializer is a lot less forgiving when it comes to generating classes from metadata.
对于一般信息,DataContractSerializer在从元数据生成类时要宽容得多 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.