【问题标题】:Groovy/Grails Using WSClient to consume .net web serviceGroovy/Grails 使用 WSClient 来使用 .net Web 服务
【发布时间】:2010-03-29 12:26:57
【问题描述】:

我对 Grails/Groovy/Web 服务都很陌生,我正在使用 .net Web 服务..

我有一些代码使用 grails WS-client 插件连接到服务:

WebService webService

 def result = {
 def wsdl =  
  ApplicationHolder.application.parentContext.getResource('WEB-INF/productsSoap.wsdl')

def proxy = webService.getClient(wsdl.getURL().toString())
def productTypeListResponse = proxy.ProductTypeList()

}

我还使用soapUI 来检查从web 服务返回的数据,它给出了..

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
  <ProductTypeListResponse xmlns="http://tempuri.org/">
     <ProductTypeListResult>
        <xs:schema id="ProductTypeListResult" xmlns=""
 xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
           <xs:element name="ProductTypeListResult" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
              <xs:complexType>
                 <xs:choice minOccurs="0" maxOccurs="unbounded">
                    <xs:element name="ProductTypeListResult">
                       <xs:complexType>
                          <xs:sequence>
                             <xs:element name="PRD_TypeId" type="xs:int" minOccurs="0"/>
                             <xs:element name="PRD_TypeName" type="xs:string" minOccurs="0"/>
                             <xs:element name="PRD_Type" type="xs:string" minOccurs="0"/>
                          </xs:sequence>
                       </xs:complexType>
                    </xs:element>
                 </xs:choice>
              </xs:complexType>
           </xs:element>
        </xs:schema>
        <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
           <ProductTypeListResult xmlns="">
              <ProductTypeListResult diffgr:id="ProductTypeListResult1" msdata:rowOrder="0">
                 <PRD_TypeId>2</PRD_TypeId>
                 <PRD_TypeName>ProdType2</PRD_TypeName>
                 <PRD_Type>S</PRD_Type>
              </ProductTypeListResult>
              <ProductTypeListResult diffgr:id="ProductTypeListResult2" msdata:rowOrder="1">
                 <PRD_TypeId>3</PRD_TypeId>
                 <PRD_TypeName>ProdType3</PRD_TypeName>
                 <PRD_Type>C</PRD_Type>
              </ProductTypeListResult>
              <ProductTypeListResult diffgr:id="ProductTypeListResult3" msdata:rowOrder="2">
                 <PRD_TypeId>4</PRD_TypeId>
                 <PRD_TypeName>ProdType4</PRD_TypeName>
              </ProductTypeListResult>
           </ProductTypeListResult>
        </diffgr:diffgram>
     </ProductTypeListResult>
  </ProductTypeListResponse>

> 这是一个.net数据集..

所以我的问题是如何使用我的 productTypeListResponse 获取信息?任何人都可以给我一个指针吗?

【问题讨论】:

    标签: grails groovy web-services


    【解决方案1】:

    WS 客户端应该生成正确的代码来访问结果。 .net服务生成的wsdl我不是很了解,但是你应该有诸如

    之类的方法
    productTypeListResponse.ProductTypeListResult
    

    在您的响应对象上。查看 groovy WS 客户端 site 上的示例。

    恕我直言,我建议您使用更成熟的库,例如 spring ws

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-24
      • 2011-03-02
      • 1970-01-01
      • 1970-01-01
      • 2016-08-02
      相关资源
      最近更新 更多