Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从另一个WCF调用Web服务以返回包含和对象为数据成员的数据协定 /*服务合同*/ [服务合同] 公共界面的开放性 { [经营合同] CustomerDetailGetCustomer(字符串entityID); //字符串GetCustomer(字符串entityID); [经营合同] List GetCustomerList(列表实体IDList); } /*数据合同*/ [数据合同] 公共类客户详细信息 { [数据成员] public Customer customerDetail;//客户在我调用的Web服务中定义 } /*实际服务合同执行情况*/ 公共CustomerDetailGetCustomer(字符串ID) { 第三方tpws=新的第三方(); var c=tpws.GetCustomerByCustomerID(ID); CustomerDetail cd=新CustomerDetail(); 999 cd.customerDetail=c[0]; 返回光盘; }_C#_Wcf_Wcf Binding_Wcf Client - Fatal编程技术网

C# 如何从另一个WCF调用Web服务以返回包含和对象为数据成员的数据协定 /*服务合同*/ [服务合同] 公共界面的开放性 { [经营合同] CustomerDetailGetCustomer(字符串entityID); //字符串GetCustomer(字符串entityID); [经营合同] List GetCustomerList(列表实体IDList); } /*数据合同*/ [数据合同] 公共类客户详细信息 { [数据成员] public Customer customerDetail;//客户在我调用的Web服务中定义 } /*实际服务合同执行情况*/ 公共CustomerDetailGetCustomer(字符串ID) { 第三方tpws=新的第三方(); var c=tpws.GetCustomerByCustomerID(ID); CustomerDetail cd=新CustomerDetail(); 999 cd.customerDetail=c[0]; 返回光盘; }

C# 如何从另一个WCF调用Web服务以返回包含和对象为数据成员的数据协定 /*服务合同*/ [服务合同] 公共界面的开放性 { [经营合同] CustomerDetailGetCustomer(字符串entityID); //字符串GetCustomer(字符串entityID); [经营合同] List GetCustomerList(列表实体IDList); } /*数据合同*/ [数据合同] 公共类客户详细信息 { [数据成员] public Customer customerDetail;//客户在我调用的Web服务中定义 } /*实际服务合同执行情况*/ 公共CustomerDetailGetCustomer(字符串ID) { 第三方tpws=新的第三方(); var c=tpws.GetCustomerByCustomerID(ID); CustomerDetail cd=新CustomerDetail(); 999 cd.customerDetail=c[0]; 返回光盘; },c#,wcf,wcf-binding,wcf-client,C#,Wcf,Wcf Binding,Wcf Client,当我在VS2010中使用上面标记为999的行上的断点运行此程序时,一切正常,但返回在WCF测试客户端中无法显示任何内容-返回和错误-在接收对…的HTTP响应时发生错误。这只是一个猜测,但在调试器的“999”行之前停止然后看看c中的内容。我打赌c.Length==0您是否验证了类型“Customer”是可序列化的(是否用DataContractAttribute、SerializableAttribute或类似的属性修饰)?在帖子中,我说它在第999行运行良好-这意味着我检查了c[0]的内容使用Q

当我在VS2010中使用上面标记为999的行上的断点运行此程序时,一切正常,但返回在WCF测试客户端中无法显示任何内容-返回和错误-在接收对…的HTTP响应时发生错误。

这只是一个猜测,但在调试器的“999”行之前停止然后看看
c
中的内容。我打赌
c.Length==0

您是否验证了类型“Customer”是可序列化的(是否用DataContractAttribute、SerializableAttribute或类似的属性修饰)?

在帖子中,我说它在第999行运行良好-这意味着我检查了c[0]的内容使用QuickView时,它的数据与预期完全一致,但返回到WCT测试客户端时出现错误-不确定数据是否太大?!?!?!你没有具体说明“它起作用”是什么意思。许多开发人员在写同一句话时,在第999行之前都会说“我单步走了,没有抛出异常”。很抱歉,信息错误-我单步走了,在第999行之前没有异常。i、 e.归还光盘;(返回到客户端失败,出现错误-在接收对的HTTP响应时出错…)在接收对的HTTP响应时出错。这可能是由于服务端点绑定未使用HTTP协议造成的。这也可能是由于服务器中止了HTTP请求上下文(可能是由于服务关闭)。有关更多详细信息,请参阅服务器日志。我认为“Customer”是可序列化的,因为在标记为999的行中,c[0]具有数据,并且我认为只有在web服务调用tpws.GetCustomerByCustomerID(ID)时才可以返回序列化数据-如果我的假设是错误的,请更正我。仅仅因为客户类是由您从中接收对象的web服务序列化的,并不一定意味着您的应用程序将该对象定义为可序列化的(当然,除非两个web服务共享一个定义该类的公共程序集)。那么,我应该如何使我的程序集中的Customer可序列化?您可以提供Customer类以供审阅吗?我没有Customer类-只能通过web服务引用-对象浏览器访问它
/* SERVICE CONTRACT */
[ServiceContract]
public interface IEntity
{
[OperationContract]
CustomerDetail GetCustomer(string entityID);
//string GetCustomer(string entityID);
[OperationContract]
List<CustomerDetail> GetCustomerList(List<string> entityIDList);
}

/* DATA CONTRACT */
[DataContract]
public class CustomerDetail
{
[DataMember]
public Customer customerDetail; //Customer is defined in the webservice i'm calling
}

/* Actual service contract implementation */
public CustomerDetail GetCustomer(string ID)
{
ThirdParty tpws = new ThirdParty();
var c = tpws.GetCustomerByCustomerID(ID);
CustomerDetail cd = new CustomerDetail();
999         cd.customerDetail = c[0];
return cd;
}