问题
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