WebException: The server committed a protocol violation. Section=ResponseStatusLine (call Marketo SOAP API)

纵饮孤独 提交于 2019-12-10 18:33:25

问题


I'm trying to call the Marketo SOAP Webservice via ASP.NET / C#. I successfully added the web service reference and tried to call it with this line of code:

SuccessGetLead lead = service.getLead(paramsgetlead);

The problem is I also get this exception:

[WebException: The server committed a protocol violation. Section=ResponseStatusLine]

System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request) +263

System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request) +4

System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +172

com.marketo.soap.MktMktowsApiService.getLead(ParamsGetLead paramsGetLead) in c:\Users\hubert.grininger\AppData\Local\Temp\Temporary ASP.NET Files\dynaweb2007\82e21235\d41bf12a\App_WebReferences.liqikruc.7.cs:206

_test_marketo.Page_Load(Object sender, EventArgs e) in d:\workspace_c\dynaweb2007_test\marketo.aspx.cs:48

System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14

System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35

System.Web.UI.Control.OnLoad(EventArgs e) +99

System.Web.UI.Control.LoadRecursive() +50

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

I also tried adding

<system.net>
   <settings>
       <httpWebRequest useUnsafeHeaderParsing = "true" />
   </settings>
</system.net> 

but that didn't help either.

I think the request is never sent to Marketo but the error already occurs on my end.

Thanks for any help or hint.


回答1:


Solved. Problem was that the wsdl (provided by Marketo) wrongly pointed to localhost as webservice endpoint. I programmatically set the URL via WebServiceObject.Url property and it works now.




回答2:


Just try to use HTTP/1.0 instead of HTTP/1.1

look at the following code

objWebRequest.ProtocolVersion = System.Net.HttpVersion.Version10;

It worked for me ;-)



来源:https://stackoverflow.com/questions/4279070/webexception-the-server-committed-a-protocol-violation-section-responsestatusl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!