獲取試圖執行CRM Web服務時以下錯誤\錯誤請求415
代碼
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 0; //Use AD authentication
token.OrganizationName = "Organization";
CrmService service= new CrmService();
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
service.PreAuthenticate=true;
WhoAmIRequest whoami = new WhoAmIRequest();
WhoAmIResponse whoResp = ((WhoAmIResponse)(service.Execute(whoami)));
配置設置:
<add key="CrmSdk.CrmServiceWsdl" value="http://server/organization/XRMServices/2011/Organization.svc/web"/>
錯誤:
System.Net.WebException:請求失敗,HTTP狀態415:無法處理消息,因爲內容類型爲'text/xml; charset = utf-8'不是預期的類型'application/soap + xml; charset = utf-8'..
如果我改變我的配置設置,如下所示,我得到「壞請求」。
配置設置:
<add key="CrmSdk.CrmServiceWsdl" value="http://server/organization/XRMServices/2011/Organization.svc/web"/>
錯誤:
The message with Action 'http://schemas.microsoft.com/crm/2007/WebServices/Execute' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).