我正在处理一个问题,我的控制台应用程序尝试通过WCF服务发送数据。我已经成功地通过另一个使用相同配置的WCF服务在我的其他控制台应用程序中发送了另一种类型的数据。
对于我在两个控制台应用程序中使用的配置:
var binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Basic;
binding.MaxReceivedMessageSize = 2147483647;
var endpoint =new System.ServiceModel.EndpointAddress("the end point");
var theClient = new MyClient(binding,endpoint);
theClient .ClientCredentials.UserName.UserName = "Username";
theClient .ClientCredentials.UserName.Password = "Password";
在完成这种配置后,我使用了发送数据的方法。我还尝试通过Postman Chrome扩展程序发送从Fiddler获取的xml数据。我能够通过Postman发送xml,但不能在控制台应用程序中发送。我认为我的配置存在问题。堆栈跟踪:
Unrecognized message version.
Server stack trace:
at System.ServiceModel.Channels.ReceivedMessage.ReadStartEnvelope(XmlDictionaryReader reader)
at System.ServiceModel.Channels.BufferedMessage..ctor(IBufferedMessageData messageData, RecycledMessageState recycledMessageState, Boolean[] understoodHeaders, Boolean understoodHeadersModified)
at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.ReadMessage(ArraySegment`1 buffer, BufferManager bufferManager, String contentType)
at System.ServiceModel.Channels.HttpInput.DecodeBufferedMessage(ArraySegment`1 buffer, Stream inputStream)
at System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(Stream inputStream)
at System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(HttpRequestMessage httpRequestMessage, Exception& requestException)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.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)
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 Integrator.WCFSer.Z_BAPI_SLS_ORD_CREATE_WITH_DEL.ZBapiSlsOrdCreateWithDel(ZBapiSlsOrdCreateWithDelRequest request)
at Integrator.WCFSer.Z_BAPI_SLS_ORD_CREATE_WITH_DELClient.Integrator.WCFSer.Z_BAPI_SLS_ORD_CREATE_WITH_DEL.ZBapiSlsOrdCreateWithDel(ZBapiSlsOrdCreateWithDelRequest request)
at Integrator.WCFSer.Z_BAPI_SLS_ORD_CREATE_WITH_DELClient.ZBapiSlsOrdCreateWithDel(ZBapiSlsOrdCreateWithDel ZBapiSlsOrdCreateWithDel1)
at Integrator.Program.Main(String[] args) mscorlibz\Integrator\Program.cs:line 113 mscorlib
有什么建议吗?