我在本地機器上使用IIS 7.5和PHP 5.6(測試)託管一個magento webshop。這家商店工作得很好,但現在我想用Visual Studio 2013創建一個單獨的應用程序。這些是我採取的步驟:在C#中調用Magento SOAP V2服務的問題#
- 我已經添加了域名「www.domain.com .local「我的主機文件指向我的本地主機(www.domain.com.local - > 127.0.0.1)
- 我在我的IIS上創建了一個新的網站,並添加了一個新的綁定(www.domain.com。地方 - 參見圖1)
- 我添加WINCACHE擴展與PHP管理和PHP版本設置爲5.6
- 在Magento的後端啓用WS-I遵從性(系統>配置> Magento的核心API)
- 創建SOAP角色和用戶(資源訪問=所有)
- 打開Visual Studio 2013,並創建一個新的控制檯應用程序
- 添加新的服務引用(http://www.domain.com.local/index.php/api/v2_soap/?wsdl)
- 嘗試登錄 - 這不是工作像它應該是
這裏是我的一段代碼:
class Program
{
static void Main(string[] args)
{
MainAsync(args).Wait();
}
static async Task MainAsync(string[] args)
{
using (var proxy = new Mage_Api_Model_Server_Wsi_HandlerPortTypeClient())
{
try
{
var loginResponse = await proxy.loginAsync("soap-admin", "xxxxxxxxx"); // api key
var sessionId = loginResponse.result;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadLine();
}
}
}
這是我得到的錯誤:
The content type text/xml; charset=utf-8,text/xml; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 297 bytes of the response were: '<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento">
<SOAP-ENV:Body>
<ns1:loginResponseParam>
<result>13fa067676759c3ce8ddd61c386b6d5c</result>
</ns1:loginResponseParam>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
'.
因此,大家可以看到,我得到我的sessionId但持續看到這個錯誤。我也用小提琴來調查並得到正確的答案:HTTP 200 OK。有人知道問題可能是什麼嗎?它與IIS有關嗎?本地主機相關?
(當我將url添加爲web引用時,它工作得很好 - 舊的webservice方法)。
相關信息我已閱讀並嘗試(沒有成功):
- C# SOAP - Error in deserializing body of reply message (Magento API)
- C#+Magento API V2:The content type text/xml; charset=utf-8,text/xml; charset=UTF-8 of the response message does not match