2010-03-29 64 views
1

我是很新,這兩個的Grails/Groovy中/ Web服務,我消耗了.NET Web服務..的Groovy/Grails的使用WSClient消費.NET Web服務

我有一些代碼連接到服務使用Grails WS-客戶端插件:

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的信息?任何人都可以給我一個指針?

回答

0

WS客戶端應該生成正確的代碼來訪問結果。我不完全瞭解.net服務生成的wsdl,但您應該在響應對象上使用如下方法:

productTypeListResponse.ProductTypeListResult 

。檢查Groovy WS客戶端site上的示例。

恕我直言,我會建議你使用更成熟的圖書館,如spring ws