【问题标题】:Generate a Web Service Client in WS-I compliance mode以 WS-I 合规模式生成 Web 服务客户端
【发布时间】:2012-09-03 14:46:19
【问题描述】:


我正在尝试使用 Visual Studio 2010 创建一个 Web 服务客户端。 如果我使用版本 SOAP V2 中的 wsdl 文件,客户端运行良好。
当我在 Magento 中将属性 WS-I Compliance 设置为 Yes 并在 VS2010 中重新编译 Web 服务客户端时,它不起作用!!!某些方法从生成的 WSDL 文件中消失。

如果我使用工具wsimport 生成Java Web 服务客户端,我也发现了同样的问题。
知道发生了什么吗?

【问题讨论】:

    标签: web-services magento soap ws-i


    【解决方案1】:

    我遇到了同样的问题,我没有注释掉 catalogProductAttributeRemove,而是实际上查看了缺少的内容并将附加部分添加到我的 wsi.xml 文件中。感谢 Juanma R. 为我指出需要更正的文件的方向。

    我引用了 catalogProductAttributeCreate 的条目,作为解决此问题可能需要存在的其他部分的参考点。我对 WSDL 真的一无所知,只是试着寻找可能缺少的东西。

    更改文件后,我刷新了 Magento 中的所有缓存,并确认新条目显示在 /index.php/api/v2_soap?wsdl=1 的 WSDL 文件中。然后我删除了添加到 VS 2010 的 Web 引用,并再次执行了添加 Web 引用的步骤。这次添加后我没有错误。

    我正在修补的 Magento 版本是 Magento Enterprise 1.12.0.2,但我希望它适用于与 catalogProductAttributeRemove 显示相同错误的其他版本。

    这是我在 wsi.xml 文件中更改的内容的快速差异:

    *** Z:\mage-1-12-0-2.dev\htdocs\app\code\core\Mage\Catalog\etc\wsi - Copy.xml backup    Tue Jul 3 12:08:31 2012 UTC
    --- Z:\mage-1-12-0-2.dev\htdocs\app\code\core\Mage\Catalog\etc\wsi.xml  Fri Nov 9 18:40:58 2012 UTC
    ***************
    *** 1509,1520 ****
                      <xsd:complexType>
                          <xsd:sequence>
                              <xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:string" />
                          </xsd:sequence>
                      </xsd:complexType>
                  </xsd:element>
              </xsd:schema>
          </wsdl:types>
          <wsdl:message name="catalogProductCurrentStoreRequest">
              <wsdl:part name="parameters" element="typens:catalogProductCurrentStoreRequestParam" />
          </wsdl:message>
          <wsdl:message name="catalogProductCurrentStoreResponse">
    --- 1509,1540 ----
                      <xsd:complexType>
                          <xsd:sequence>
                              <xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:string" />
                          </xsd:sequence>
                      </xsd:complexType>
                  </xsd:element>
    + 
    +           
    + <!-- Added by Matt Johnson 2012-11-09 to fix VS 2010 support of SOAP reference -->
    +           <xsd:element name="catalogProductAttributeRemoveRequestParam">
    +               <xsd:complexType>
    +                   <xsd:sequence>
    +                       <xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
    +                       <xsd:element minOccurs="1" maxOccurs="1" name="attribute" type="xsd:string" />
    +                   </xsd:sequence>
    +               </xsd:complexType>
    +           </xsd:element>
    +           <xsd:element name="catalogProductAttributeRemoveResponseParam">
    +               <xsd:complexType>
    +                   <xsd:sequence>
    +                       <xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />
    +                   </xsd:sequence>
    +               </xsd:complexType>
    +           </xsd:element>
    +           
    +           
              </xsd:schema>
          </wsdl:types>
          <wsdl:message name="catalogProductCurrentStoreRequest">
              <wsdl:part name="parameters" element="typens:catalogProductCurrentStoreRequestParam" />
          </wsdl:message>
          <wsdl:message name="catalogProductCurrentStoreResponse">
    ***************
    *** 1883,1894 ****
          <wsdl:message name="catalogProductAttributeCreateRequest">
              <wsdl:part name="parameters" element="typens:catalogProductAttributeCreateRequestParam" />
          </wsdl:message>
          <wsdl:message name="catalogProductAttributeCreateResponse">
              <wsdl:part name="parameters" element="typens:catalogProductAttributeCreateResponseParam" />
          </wsdl:message>
          <wsdl:portType name="{{var wsdl.handler}}PortType">
              <wsdl:operation name="catalogCategoryCurrentStore">
                  <wsdl:documentation>Set_Get current store view</wsdl:documentation>
                  <wsdl:input message="typens:catalogCategoryCurrentStoreRequest" />
                  <wsdl:output message="typens:catalogCategoryCurrentStoreResponse" />
              </wsdl:operation>
    --- 1903,1923 ----
          <wsdl:message name="catalogProductAttributeCreateRequest">
              <wsdl:part name="parameters" element="typens:catalogProductAttributeCreateRequestParam" />
          </wsdl:message>
          <wsdl:message name="catalogProductAttributeCreateResponse">
              <wsdl:part name="parameters" element="typens:catalogProductAttributeCreateResponseParam" />
          </wsdl:message>
    + 
    + <!-- Added by Matt Johnson 2012-11-09 to fix VS 2010 support of SOAP reference -->
    +   <wsdl:message name="catalogProductAttributeRemoveRequest">
    +       <wsdl:part name="parameters" element="typens:catalogProductAttributeRemoveRequestParam" />
    +   </wsdl:message>
    +   <wsdl:message name="catalogProductAttributeRemoveResponse">
    +       <wsdl:part name="parameters" element="typens:catalogProductAttributeRemoveResponseParam" />
    +   </wsdl:message> 
    +   
          <wsdl:portType name="{{var wsdl.handler}}PortType">
              <wsdl:operation name="catalogCategoryCurrentStore">
                  <wsdl:documentation>Set_Get current store view</wsdl:documentation>
                  <wsdl:input message="typens:catalogCategoryCurrentStoreRequest" />
                  <wsdl:output message="typens:catalogCategoryCurrentStoreResponse" />
              </wsdl:operation>
    ***************
    *** 2760,2771 ****
                      <soap:body use="literal" />
                  </wsdl:input>
                  <wsdl:output>
                      <soap:body use="literal" />
                  </wsdl:output>
              </wsdl:operation>
          </wsdl:binding>
          <wsdl:service name="{{var wsdl.name}}Service">
              <wsdl:port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
                  <soap:address location="{{var wsdl.url}}" />
              </wsdl:port>
          </wsdl:service>
    --- 2789,2814 ----
                      <soap:body use="literal" />
                  </wsdl:input>
                  <wsdl:output>
                      <soap:body use="literal" />
                  </wsdl:output>
              </wsdl:operation>
    + 
    + 
    + <!-- Added by Matt Johnson 2012-11-09 to fix VS 2010 support of SOAP reference -->        
    +       <wsdl:operation name="catalogProductAttributeRemove">
    +           <soap:operation soapAction="" />
    +           <wsdl:input>
    +               <soap:body use="literal" />
    +           </wsdl:input>
    +           <wsdl:output>
    +               <soap:body use="literal" />
    +           </wsdl:output>
    +       </wsdl:operation>
    +       
    +       
          </wsdl:binding>
          <wsdl:service name="{{var wsdl.name}}Service">
              <wsdl:port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
                  <soap:address location="{{var wsdl.url}}" />
              </wsdl:port>
          </wsdl:service>
    

    【讨论】:

      【解决方案2】:

      原来的 Magento Core 代码有一个错误,与操作“catalogProductAttributeRemove”(模块 core/Mage/Catalog)有关。

      为了解决这个问题,我在模块目录的 wsi.xml 文件中注释了以下操作

       <!--wsdl:operation name="catalogProductAttributeRemove">
          <wsdl:documentation>Delete attribute</wsdl:documentation>
          <wsdl:input message="typens:catalogProductAttributeRemoveRequest" />
          <wsdl:output message="typens:catalogProductAttributeRemoveResponse" />
      </wsdl:operation-->
      

      之后使用VS2010自动构建Web Service Client就完美了!

      【讨论】:

        【解决方案3】:

        我将 diff 从 1.7.2 版包含到 wsi.xml 中并上传了 here

        所以,如果你不能正确读取 diff,你可以直接使用这个文件。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2014-03-25
          • 1970-01-01
          • 1970-01-01
          • 2016-11-15
          • 2015-09-09
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多