日期:2014-05-17  浏览次数:21132 次

调用WebServicec出错
 调用如下WebService
 [WebMethod]   
public void  HelloWorld() {
 string url = "http://192.168.2.45/INA_WebService/Service.asmx";
        ServiceReference.ServiceSoapClient webservice = new ServiceReference.ServiceSoapClient("ServiceSoap", url);
        string a = "xla";
        string b = "123";
        webservice.login(a, b);
}
出现如下错误,请问大家这是什么错误,怎么改

System.ServiceModel.ProtocolException: SOAP 消息需要 HTTP 内容类型标头,但是未找到此类标头。

Server stack trace: 
   在 System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException)
   在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   在 System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   在 System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   在 ServiceReference.ServiceSoap.login(String userName, String password)
   在 ServiceReference.ServiceSoapClient.login(String userName, String password) 位置 c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\website1\fc8965ee\f4aeb59b\App_WebReferences.otytlksb.0.cs:行号 83
   在 Service.HelloWorld() 位置 e:\INA_WebService\WebSite1\App_Code\Service.cs:行号 27


------解决方案--------------------
可能协议有问题,重新添加服务引用,查看("ServiceSoap", url)里面参数及web.config配置问题