开发者

Groovy/Grails Using WSClient to consume .net web service

I'm pretty new to both Grails/Groovy/Web services and i'm consuming a .net web service ..

I have some code connects to the service using grails WS-client plugin :

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()

}

I also used soapUI to examine the data returned from the web service which gave ..

<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 na开发者_如何学JAVAme="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>

> which is a .net dataset ..

So my question is how do i get at the information using my productTypeListResponse ? Can anyone give me a pointer ?


The WS Client should generate the proper code to access the result. I do not fully understand the wsdl that the .net service generates, but you should have methods such as

productTypeListResponse.ProductTypeListResult

on your response object. Check the example on groovy WS client site.

IMHO I would suggest you to use a more mature library such as spring ws

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜