简体   繁体   English

WCF收到HTTP响应时发生错误

[英]WCF An error occurred while receiving the HTTP response

Here's what my WCF service should be returning. 这是我的WCF服务应该返回的内容。 When I command PaymentData out of ResponseModel and add other DataMembers in that class it works. 当我从ResponseModel中命令PaymentData并在该类中添加其他DataMembers时,它将起作用。

[DataContract]
public class ResponseModel
{
    [DataMember]
    public PaymentData PaymentData { get; set; }
}

Here's the PaymentData class: 这是PaymentData类:

[DataContract]
public class PaymentData
{
    [DataMember]
    public PaymentType PaymentType { get; set; }
    [DataMember]
    public string CardNumber { get; set; }
    [DataMember]
    public DateTime ExpirationDate { get; set; }
    /// <summary>
    /// If true, then the CardNumber property will contain the token
    /// </summary>
    [DataMember]
    public bool IsCardNumberTokenized { get; set; }
    /// <summary>
    /// Number on back of credit cards. This value CANNOT be stored anywhere
    /// </summary>
    [DataMember]
    public string CardSecurityValue { get; set; }
    [DataMember]
    public CardSecurityPresence CardSecurityPresence { get; set; }
}

... and the enums defined in the PaymentData class ...以及PaymentData类中定义的枚举

[DataContract(Name = "CardSecurityPresenceEnum")]
public enum CardSecurityPresence
{
    [EnumMember(Value = "1")]
    IsPresent = 1,
    [EnumMember(Value = "2")]
    Illegible = 2,
    [EnumMember(Value = "9")]
    NoCodeOnCard = 9,
    [EnumMember(Value = " ")]
    NotSent
}

[DataContract(Name = "PaymentTypeEnum")]
public enum PaymentType
{
    [EnumMember]
    Visa = CMPWSApiService.TransactionMop.VI,
    [EnumMember]
    MasterCard = CMPWSApiService.TransactionMop.MC,
    [EnumMember]
    AmericanExpress = CMPWSApiService.TransactionMop.AX,
    [EnumMember]
    Discover = CMPWSApiService.TransactionMop.DI,
    [EnumMember]
    PayPal = CMPWSApiService.TransactionMop.PP,
    [EnumMember]
    BillMeLater = CMPWSApiService.TransactionMop.BL
}

Does the serialization not like that my variable names have the same names as their classes? 序列化是否不像我的变量名和它们的类一样?

Here's the error from the WCFTest Client: 这是来自WCFTest客户端的错误:

An error occurred while receiving the HTTP response to [service url omitted]. 收到对[省略的服务网址]的HTTP响应时发生错误。 This could be due to the service endpoint binding not using the HTTP protocol. 这可能是由于服务端点绑定未使用HTTP协议。 This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). 这也可能是由于一个HTTP请求上下文服务器(可能是由于服务关停)被中止。 See server logs for more details. 有关更多详细信息,请参见服务器日志。

Server stack trace: at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason) 服务器堆栈跟踪:位于System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException WebException,HttpWebRequest请求,HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 在System.ServiceModel.Channels.RequestChannel.Request(消息,TimeSpan超时)处在System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan超时),在System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息,TimeSpan) System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,布尔型单向,ProxyOperationRuntime操作,在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime)处的Object [] ins,Object [] outs,TimeSpan超时)操作)在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage消息)

Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at ICreditCardService.TestAuth() at CreditCardServiceClient.TestAuth() 异常重新抛出为[0]:System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&msgData,Int32类型)的System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)在ICreditCardService.TestAuth( )在CreditCardServiceClient.TestAuth()

Inner Exception: The underlying connection was closed: An unexpected error occurred on a receive. 内部异常:基础连接已关闭:接收时发生意外错误。 at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 在System.Net.HttpWebRequest.GetResponse()在System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan超时)

Inner Exception: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. 内部异常:无法从传输连接读取数据:远程主机强行关闭了现有连接。 at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) 在System.Net.Connection.SyncRead处为System.Net.PooledStream.Read(在System.Net.Sockets.NetworkStream.Read(Byte []缓冲区,Int32偏移量,Int32大小)处。 (HttpWebRequest请求,布尔userRetrievedStream,布尔probeRead)

Inner Exception: An existing connection was forcibly closed by the remote host at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) 内部异常:远程主机在System.Net.Sockets.NetworkStream.Read(Byte []缓冲区,Int32偏移量,Int32大小)

In CardSecurityPresenceEnum I had a enum member called NotSent that was not initialized to a value. CardSecurityPresenceEnum我有一个名为NotSent的枚举成员,该成员没有初始化为值。 For some reason that was hanging things up. 由于某种原因,这使事情挂起来。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WCF收到HTTP响应时发生错误 - WCF An error occurred while receiving the HTTP response WCF-收到HTTP响应时发生错误 - WCF -An error occurred while receiving the HTTP response 接收 HTTP 响应时出错 WCF - An error occurred while receiving the HTTP response WCF WCF - 接收对 http://xxxxx/Service/ 的 HTTP 响应时出错 - WCF - An error occurred while receiving the HTTP response to http://xxxxx/Service/ WCF-仅生产服务器-收到HTTP响应时发生错误 - WCF - Production server only - An error occurred while receiving the HTTP response 从WCF服务接收HTTP响应时发生错误 - Error occurred while receiving HTTP response from WCF service WCF服务抛出:收到HTTP响应时发生错误 - WCF Service throw : An error occurred while receiving the HTTP response 收到HTTP响应错误时发生错误 - An error occurred while receiving the HTTP response error WCF SOAP 服务出现错误接收到 HTTP 对 Z80791B3AE7002CB88C246/FAA7 服务的响应时发生错误 - WCF SOAP service give an error An error occurred while receiving the HTTP response to http://localhost/Service1.svc 从WCF函数返回DataContract时,出现此错误:“接收HTTP响应时发生错误” - While returning a DataContract from a WCF function, I'm getting this error: “An error occurred while receiving the HTTP response”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM