我的控制台应用程序试图通过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但不能在控制台应用程序中发送。我认为我的配置存在问题。 Stacktrace:
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
任何建议?