title: "Unrecognized message version" while calling SAP PI endpoint from .NET
body: <p>I am using an <code>webserviceinvoking</code> class to call SAP PI from a .NET with C# Service.</p>
  
  <p>I am using the following method to do this:</p>
  
  <pre><code>public object InvokeMethod(string serviceName, string methodName, params object[] args)
  {
      System.ServiceModel.Channels.Binding defaultBinding = new BasicHttpBinding(BasicHttpSecurityMode.None);
      if (this.credentials != null)
      {
          ((BasicHttpBinding)defaultBinding).Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
          ((BasicHttpBinding)defaultBinding).Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; //.Ntlm;
      }
  
      object obj = this.webServiceAssembly.CreateInstance(serviceName, false, BindingFlags.CreateInstance, null, new object[] { defaultBinding, new EndpointAddress(this.webServiceUri.ToString()) }, null, null);
  
      Type type = obj.GetType();
  
      if (this.credentials != null)
      {
          PropertyInfo piClientCreds = type.GetProperty("ClientCredentials");
          ClientCredentials creds = (ClientCredentials)piClientCreds.GetValue(obj, null);
          creds.UserName.UserName = this.credentials.UserName;
          creds.UserName.Password = this.credentials.Password;
      }
  
      return type.InvokeMember(methodName, BindingFlags.InvokeMethod, null, obj, args);
  }
  </code></pre>
  
  <p>However calling it gives me an Unrecognized message version. exception:</p>
  
  <pre><code>{System.ServiceModel.CommunicationException: 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.MessageEncoder.ReadMessage(Stream stream, BufferManager bufferManager, Int32 maxBufferSize, String contentType)
     at System.ServiceModel.Channels.HttpInput.ReadChunkedBufferedMessage(Stream inputStream)
     at System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(Exception&amp; requestException)
     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)
  
  Exception rethrown at [0]: 
     at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
     at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)
     at SIOS_Sync_CRMAccount.SIOS_Sync_CRMAccount(SIOS_Sync_CRMAccountRequest request)
     at SIOS_Sync_CRMAccountClient.SIOS_Sync_CRMAccount.SIOS_Sync_CRMAccount(SIOS_Sync_CRMAccountRequest request)
     at SIOS_Sync_CRMAccountClient.SIOS_Sync_CRMAccount(DT_CRMAccount MT_Sync_CRMAccount_request)}
  </code></pre>
  
  <p>Wireshark XML output to webservice:</p>
  
  <pre><code>&lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
      &lt;s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
          &lt;MT_Sync_CRMAccount_request xmlns="http://microsoft.com/crm/accounts"&gt;
              &lt;recordActionType xmlns=""&gt;1&lt;/recordActionType&gt;
              &lt;accountnumber xmlns=""&gt;3000016&lt;/accountnumber&gt;
              &lt;name xmlns=""&gt;Test CRM2SAP16&lt;/name&gt;
          &lt;/MT_Sync_CRMAccount_request&gt;
      &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;
  </code></pre>
  
  <p>Any help is much appreciated.</p>