WSDL请求,R中的SOAP

时间:2017-12-31 12:52:31

标签: r web-services soap wsdl

我想使用 SOAP 方法来使用网站的网络服务功能。

以下方法是手册中的内容;

WSDL地址: http://dev.gittigidiyor.com:8080/listingapi/ws/CategoryService?wsdl

服务方式签名: CategoryServiceResponse getCategories(int startOffSet,int rowCount,boolean withSpecs,boolean withDeepest,boolean withCatalog,String lang)

请求示例

<cat:getCategories>
   <startOffSet>0</startOffSet>
   <rowCount>4</rowCount>
   <withSpecs>true</withSpecs>
   <withDeepest>true</withDeepest>
   <withCatalog>true</withCatalog>
   <lang>tr</lang>
</cat:getCategories>

这是我在R中尝试过的。

      library(RCurl)

        headerFields =
          c(Accept = "text/xml",
            'Content-Type' = "text/xml; charset=utf-8",
            SOAPAction = "")


             body <- '<cat:getCategories>
   <startOffSet>0</startOffSet>
   <rowCount>4</rowCount>
   <withSpecs>true</withSpecs>
   <withDeepest>true</withDeepest>
   <withCatalog>true</withCatalog>
   <lang>tr</lang>
</cat:getCategories>'





        curlPerform(url = "http://dev.gittigidiyor.com:8080/listingapi/ws/CategoryService?wsdl",
                                  httpheader = headerFields,
                                  postfields = body
                                  )

但最后,我只有输出;

OK 
 0 

然而,它应该像手册一样;

<cat:getCategoriesResponse xmlns:cat="http://category.anonymous.ws.listingapi.gg.com">
   <return>
      <ackCode>success</ackCode>
      <responseTime>29/06/2010 13:39:19</responseTime>
      <timeElapsed>2 ms</timeElapsed>
      <categoryCount>3849</categoryCount>
      <categories>
         <category hasCatalog="false" deepest="false">
            <categoryCode>a</categoryCode>
            <categoryName>Antikalar &amp; Sanat</categoryName>
         </category>
         <category hasCatalog="false" deepest="false">
            <categoryCode>aa</categoryCode>
            <categoryName>Antika Ahşap Objeler</categoryName>
            <specs>
               <spec type="Combo" name="Menşei (Orijin)">
                  <values>
                     <value>Avrupa</value>
                     <value>Osmanlı</value>
                     <value>Türkiye</value>
                     <value>Uzakdoğu</value>
                     <value>Diğer</value>
                     <value>Rusya</value>
                  </values>
               </spec>
               <spec type="Combo" required="true" name="Kondisyon">
                  <values>
                     <value>Yüksek</value>
                     <value>Orta</value>
                     <value>Düşük</value>
                  </values>
               </spec>
               <spec type="Combo" required="true" name="Durumu">
                  <values>
                     <value>Yeni</value>
                     <value>Kullanılmış</value>
                     <value>Diğer</value>
                  </values>
               </spec>
               <spec type="Combo" required="true" name="Antika / Modern">
                  <values>
                     <value>Antika</value>
                     <value>Modern</value>
                  </values>
               </spec>
               <spec type="Combo" name="Dönemler">
                  <values>
                     <value>1800 öncesi</value>
                     <value>1800 - 1849</value>
                     <value>1850 - 1899</value>
                     <value>1900 - 1940</value>
                     <value>1940 sonrası</value>
                  </values>
               </spec>
            </specs>
         </category>
         <category hasCatalog="false" deepest="true">
            <categoryCode>az</categoryCode>
            <categoryName>Diğer Antikalar &amp; Sanat</categoryName>
         </category>
         <category hasCatalog="false" deepest="false">
            <categoryCode>b</categoryCode>
            <categoryName>Bilgisayar</categoryName>
            <specs>
               <spec type="Combo" required="true" name="Durumu">
                  <values>
                     <value>Yeni, Açılmamış Kutusunda</value>
                     <value>Kullanılmış</value>
                     <value>Yeni, Kutusuz</value>
                  </values>
               </spec>
            </specs>
         </category>
      </categories>
   </return>
</cat:getCategoriesResponse>

我错过了什么?你能帮忙吗?

1 个答案:

答案 0 :(得分:1)

这可能对您有帮助

library(RCurl)

headerFields = c(Accept = "text/xml", 
                 'Content-Type' = "text/xml; charset=utf-8", SOAPAction = "")


body <- '<cat:getCategories>
         <startOffSet>0</startOffSet>
         <rowCount>4</rowCount>
         <withSpecs>true</withSpecs>
         <withDeepest>true</withDeepest>
         <withCatalog>true</withCatalog>
         <lang>tr</lang>
         </cat:getCategories>'


reader <- basicTextGatherer()


curlPerform(url = "http://dev.gittigidiyor.com:8080/listingapi/ws/CategoryService?wsdl",
                              httpheader = headerFields,
                              postfields = body,
                              writefunction = reader$update
                              )

xml <- reader$value()
xml