【发布时间】:2016-01-14 01:09:49
【问题描述】:
我们有一个 asmx Web 服务项目。当我使用 Add Service Reference 选项将它添加到项目中时,一切正常。但是,当我的同事这样做时,他得到了操作合同中定义的方法的错误签名。
通过错误的签名,我的意思是原始方法接收实体作为参数,这些实体在我同事的项目中生成为DataSet 参数(服务引用结构也不同,如图所示。我的同事有更多的东西)。我们正在使用 VS 2013。
发生了什么事?
编辑:
服务合同
[ServiceContract]
public interface INetTransTntIntegration
{
[OperationContract]
string CreateGlbTrns1LineCard(GlbTrns1LineCardEntity ent);
[OperationContract]
void CreateGlbTrns1LineCardTest();
}
生成的代码(同事的错误代码)
namespace TNT.ServiceReference {
using System.Data;
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="ServiceReference.INetTransTntIntegration")]
public interface INetTransTntIntegration {
// CODEGEN: Parameter 'CreateGlbTrns1LineCardResult' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCard", ReplyAction="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
TNT.ServiceReference.CreateGlbTrns1LineCardResponse CreateGlbTrns1LineCard(TNT.ServiceReference.CreateGlbTrns1LineCardRequest request);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCard", ReplyAction="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardResponse")]
System.Threading.Tasks.Task<TNT.ServiceReference.CreateGlbTrns1LineCardResponse> CreateGlbTrns1LineCardAsync(TNT.ServiceReference.CreateGlbTrns1LineCardRequest request);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardTest", ReplyAction="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardTestResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
void CreateGlbTrns1LineCardTest();
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardTest", ReplyAction="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardTestResponse")]
System.Threading.Tasks.Task CreateGlbTrns1LineCardTestAsync();
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="CreateGlbTrns1LineCard", WrapperNamespace="http://tempuri.org/", IsWrapped=true)]
public partial class CreateGlbTrns1LineCardRequest {
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://tempuri.org/", Order=0)]
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
public System.Data.DataSet ent;
public CreateGlbTrns1LineCardRequest() {
}
public CreateGlbTrns1LineCardRequest(System.Data.DataSet ent) {
this.ent = ent;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="CreateGlbTrns1LineCardResponse", WrapperNamespace="http://tempuri.org/", IsWrapped=true)]
public partial class CreateGlbTrns1LineCardResponse {
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://tempuri.org/", Order=0)]
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
public string CreateGlbTrns1LineCardResult;
public CreateGlbTrns1LineCardResponse() {
}
public CreateGlbTrns1LineCardResponse(string CreateGlbTrns1LineCardResult) {
this.CreateGlbTrns1LineCardResult = CreateGlbTrns1LineCardResult;
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface INetTransTntIntegrationChannel : TNT.ServiceReference.INetTransTntIntegration, System.ServiceModel.IClientChannel {
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class NetTransTntIntegrationClient : System.ServiceModel.ClientBase<TNT.ServiceReference.INetTransTntIntegration>, TNT.ServiceReference.INetTransTntIntegration {
public NetTransTntIntegrationClient() {
}
public NetTransTntIntegrationClient(string endpointConfigurationName) :
base(endpointConfigurationName) {
}
public NetTransTntIntegrationClient(string endpointConfigurationName, string remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}
public NetTransTntIntegrationClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}
public NetTransTntIntegrationClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress) {
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
TNT.ServiceReference.CreateGlbTrns1LineCardResponse TNT.ServiceReference.INetTransTntIntegration.CreateGlbTrns1LineCard(TNT.ServiceReference.CreateGlbTrns1LineCardRequest request) {
return base.Channel.CreateGlbTrns1LineCard(request);
}
public string CreateGlbTrns1LineCard(System.Data.DataSet ent) {
TNT.ServiceReference.CreateGlbTrns1LineCardRequest inValue = new TNT.ServiceReference.CreateGlbTrns1LineCardRequest();
inValue.ent = ent;
TNT.ServiceReference.CreateGlbTrns1LineCardResponse retVal = ((TNT.ServiceReference.INetTransTntIntegration)(this)).CreateGlbTrns1LineCard(inValue);
return retVal.CreateGlbTrns1LineCardResult;
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
System.Threading.Tasks.Task<TNT.ServiceReference.CreateGlbTrns1LineCardResponse> TNT.ServiceReference.INetTransTntIntegration.CreateGlbTrns1LineCardAsync(TNT.ServiceReference.CreateGlbTrns1LineCardRequest request) {
return base.Channel.CreateGlbTrns1LineCardAsync(request);
}
public System.Threading.Tasks.Task<TNT.ServiceReference.CreateGlbTrns1LineCardResponse> CreateGlbTrns1LineCardAsync(System.Data.DataSet ent) {
TNT.ServiceReference.CreateGlbTrns1LineCardRequest inValue = new TNT.ServiceReference.CreateGlbTrns1LineCardRequest();
inValue.ent = ent;
return ((TNT.ServiceReference.INetTransTntIntegration)(this)).CreateGlbTrns1LineCardAsync(inValue);
}
public void CreateGlbTrns1LineCardTest() {
base.Channel.CreateGlbTrns1LineCardTest();
}
public System.Threading.Tasks.Task CreateGlbTrns1LineCardTestAsync() {
return base.Channel.CreateGlbTrns1LineCardTestAsync();
}
}
我正确生成的代码
namespace TNT.NettransSvc {
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="NettransSvc.INetTransTntIntegration")]
public interface INetTransTntIntegration {
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCard", ReplyAction="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardResponse")]
string CreateGlbTrns1LineCard(LLMTESTADAPTER.EntityClasses.GlbTrns1LineCardEntity ent);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCard", ReplyAction="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardResponse")]
System.Threading.Tasks.Task<string> CreateGlbTrns1LineCardAsync(LLMTESTADAPTER.EntityClasses.GlbTrns1LineCardEntity ent);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardTest", ReplyAction="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardTestResponse")]
void CreateGlbTrns1LineCardTest();
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardTest", ReplyAction="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardTestResponse")]
System.Threading.Tasks.Task CreateGlbTrns1LineCardTestAsync();
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface INetTransTntIntegrationChannel : TNT.NettransSvc.INetTransTntIntegration, System.ServiceModel.IClientChannel {
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class NetTransTntIntegrationClient : System.ServiceModel.ClientBase<TNT.NettransSvc.INetTransTntIntegration>, TNT.NettransSvc.INetTransTntIntegration {
public NetTransTntIntegrationClient() {
}
public NetTransTntIntegrationClient(string endpointConfigurationName) :
base(endpointConfigurationName) {
}
public NetTransTntIntegrationClient(string endpointConfigurationName, string remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}
public NetTransTntIntegrationClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}
public NetTransTntIntegrationClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress) {
}
public string CreateGlbTrns1LineCard(LLMTESTADAPTER.EntityClasses.GlbTrns1LineCardEntity ent) {
return base.Channel.CreateGlbTrns1LineCard(ent);
}
public System.Threading.Tasks.Task<string> CreateGlbTrns1LineCardAsync(LLMTESTADAPTER.EntityClasses.GlbTrns1LineCardEntity ent) {
return base.Channel.CreateGlbTrns1LineCardAsync(ent);
}
public void CreateGlbTrns1LineCardTest() {
base.Channel.CreateGlbTrns1LineCardTest();
}
public System.Threading.Tasks.Task CreateGlbTrns1LineCardTestAsync() {
return base.Channel.CreateGlbTrns1LineCardTestAsync();
}
}
}
【问题讨论】:
-
邮政编码,不是图片。关键点必须是可谷歌搜索的。
-
@HenkHolterman 唯一可见的区别似乎是图片中的那个,否则我没有任何线索。您想查看代码的任何特定部分吗?
-
但它可能是导入对话框中的一个设置。
-
两个项目是否引用相同的程序集?特别是带有 GlbTrns1LineCardEntity 的那个?还要比较“高级”按钮下的设置。
-
再检查一次,肯定有什么不同。检查基础知识,不要假设任何事情。不正确的版本似乎不知道实体类型。
标签: c# web-services wcf asmx