0

我尝试将 magento Web 服务从https://myclient.com/api/v2_soap/index/wsdl/1加载到我的 .net 控制台测试应用程序中。我添加了服务引用,它在带有端点的 app.config 文件中生成了 basichttpbinding。

但是,当我尝试登录时,出现此错误:“SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://myclient.com/index.php/api/v2_soap/index/wsdl/1/' :需要开始标签,'<' 未找到”

有任何想法吗?

System.ServiceModel.FaultException was unhandled
  HResult=-2146233087
  Message=SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://myclient.com/index.php/api/v2_soap/index/wsdl/1/' : Start tag expected, '<' not found

  Source=mscorlib
  StackTrace:
    Server stack trace: 
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

应用程序配置:

<?xml version="1.0"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="Mage_Api_Model_Server_V2_HandlerBinding" closeTimeout="00:01:00"
           openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"      
           maxBufferPoolSize="524288000" maxBufferSize="65536000" maxReceivedMessageSize="65536000">
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>

      <endpoint address="https://myclient.com/api/v2_soap/index/wsdl/1"
          binding="basicHttpBinding" bindingConfiguration="Mage_Api_Model_Server_V2_HandlerBinding"
          contract="TattyService.Mage_Api_Model_Server_V2_HandlerPortType"
          name="Mage_Api_Model_Server_V2_HandlerPort" />
    </client>
  </system.serviceModel>
</configuration>

程序.cs:

 using (Mage_Api_Model_Server_V2_HandlerPortTypeClient proxy = new Mage_Api_Model_Server_V2_HandlerPortTypeClient())
            {
                proxy.login("username", "apikey");
            }
4

2 回答 2

0

原来是网络主机添加了额外的 SSL 层,大多数机器都没有安装它。那是浏览器可以浏览它但不能浏览它的时候。

于 2012-08-22T14:02:13.977 回答
0

通过错误“ Start tag expected, '<' not found”这句话,基本问题一定是Magento文件“ wsdl.xml”中缺少XML Start标记。

我几乎不知道最简单的解决方案,但在浏览器中成功加载 WSDL 后,您绝对可以手动浏览每一行。根据错误的行,您将必须识别 Magento 模块,然后纠正此缺陷。

希望能帮助到你。

于 2012-08-21T19:17:56.413 回答