【发布时间】:2012-02-22 10:52:29
【问题描述】:
我正在制作一个 web 服务(由于 .net req 无法转换到 wcf)。我的 WebServiceRequest 类中有其他类的列表。尝试编译代码时出现以下错误:
request.List = list;
不能隐式转换类型 'System.Collections.Generic.List' 到 'ServiceReference1.foo[]'
当我执行request.List = list.ToArray(); 时,此错误消失
但是当我运行代码时,我得到了这个异常:
接收到的 HTTP 响应时出错 http://localhost:60380/fooService/fooService.asmx。这可能是由于 到不使用 HTTP 协议的服务端点绑定。这 也可能是由于 HTTP 请求上下文被 服务器(可能是由于服务关闭)。查看服务器日志 了解更多详情。
内部异常:
底层连接已关闭:发生意外错误 一个接收。
服务器堆栈跟踪:
在 System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest 请求, HttpAbortReason abortReason)
在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(时间跨度 超时)在 System.ServiceModel.Channels.RequestChannel.Request(消息消息, TimeSpan 超时)在 System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息 消息,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannel.Call(字符串动作, Boolean oneway, ProxyOperationRuntime 操作, Object[] ins, Object[] 出局,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannel.Call(字符串动作, Boolean oneway, ProxyOperationRuntime 操作, Object[] ins, 对象 [] 出局)在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime 操作)在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 留言)在 [0] 处重新抛出异常:在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(消息数据& msgData,Int32 类型)在 ServiceReference1.testpingtestSoap.Calculatetestping(CalculatetestpingRequest1 请求)在 ServiceReference1.testpingtestSoapClient.ServiceReference1.testpingtestSoap.Calculatetestping(CalculatetestpingRequest1 请求)在 c:\Users\User\AppData\Local\Temp\Temporary ASP.NET 文件\test\2e05987f\91110734\App_WebReferences.rwmro5zd.0.cs:855 行 在 ServiceReference1.testpingtestSoapClient.Calculatetestping(CalculatetestpingRequest _request) 在 c:\Users\User\AppData\Local\Temp\Temporary ASP.NET Files\test\2e05987f\91110734\App_WebReferences.rwmro5zd.0.cs:line 862 在 testCost2.Calculatetestping() 中 c:\Users\User\Desktop\test\InfoSystem\testping\testCost2.aspx.cs:line 203 at testCost2.Submit_Go(Object sender, EventArgs e) in c:\Users\User\Desktop\test\InfoSystem\testping\testCost2.aspx.cs:line 148 在 System.Web.UI.WebControls.Button.OnClick(EventArgs e) 在 System.Web.UI.WebControls.Button.RaisePostBackEvent(字符串 事件参数)在 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(字符串 事件参数)在 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,字符串 eventArgument) 在 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
在 System.Web.UI.Page.ProcessRequestMain(布尔 includeStagesBeforeAsyncPoint,布尔型 includeStagesAfterAsyncPoint)
编辑 1: Web 服务的请求和响应类
public class Item
{
public List<string> Composites { get; set; }
public string Composites_List { get { return string.Join(", ", Composites.ToArray()); } }
public List<px> pxes { get; set; }
public List<ox> oxes { get; set; }
public List<MethodCalculationType> MethodCalculationTypes { get; set; }
public ShippingItem() { }
public void ShippingItemFill(string sku, int quantity)
{
\\this method is just written to avoid parameterless constructor error
}
public static ItemComparison = delegateItem item1, Item item2) { return item1.Area.CompareTo(item2.Area); };
}
public class Request
{
public List<Item> ItemList;
public bool showAllRatesField;
public bool m_Ignore;
public string pTextField;
public decimal TotalField;
}
public class Responce
{
public od [] ods;
}
【问题讨论】:
-
@Tobias 当我在请求中放入一个简单的字符串并且没有 List 它运行完美,如果您仍然认为这是配置问题,知道什么会被错误配置吗?
标签: c# .net list exception asmx