使用CURL发布XML会返回奇怪的字符

时间:2016-11-06 15:07:05

标签: xml curl post

我确实希望使用CURL监控Web服务。

POST适用于SOAPUI:

SoapUI output

但是当我通过命令行执行操作时,返回非常奇怪:

curl -X POST --header "Content-Type: text/xml" --data @sku.xml http://10.107.100.36:9700/wcs/ShippingDateCalculator?wsdl

这是输出:

[root@pinche ~]# curl -X POST --header "Content-Type: text/xml" --data @sku.xml http://10.107.100.36:9700/wcs/ShippingDateCalculator?wsdl
Lo???@???????~?K?@????????~???`???onL???????zŕ??????@?????z???????~????zaa???????K???????K???a????a????????anL???????z??nL???z?????????ā??م??????@?????z???~????zaa??K?????a∉?????ā??Á????????anL????????ā???nL????????ā??nL????n??a??a????La????nL????ā?n??????La????ā?nLa????????ā??nL????????ā??nL????n??a??a????La????nL????ā?n???????La????ā?nLa????????ā??nL????????ā??nL????n??a??a????La????nL????ā?n?????La????ā?nLa????????ā??nL????????ā??nL????n??a??a????La????nL????ā?n??????La????ā?nLa????????ā??nL????????ā??nL????n??a??a????La????nL????ā?n??Q??????La????ā?nLa????????ā??nL????????ā??nL????n??a??a????La????nL????ā?n??????La????ā?nLa????????ā??nL????????ā??nL????n??a??a????La????nL????ā?n???????La????ā?nLa????????ā??nL????????ā??nL????n??a??a????La????nL????ā?n?????La????ā?nLa????????ā??nL????????ā??nL????n??a??a????La????nL????ā?n??????La????ā?nLa????????ā??nL????????ā??nL????n??a??a????La????nL????ā?n??Q??????La????ā?nLa????????ā??nLa????????ā???nL??????n??La??????nLa???z?????????ā??م??????nLa???????z??nLa???????zŕ??????n[root@pinche]#

Shell output

遵循sku.xml的内容:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ship="http://cl.hites/ShippingDateCalculator/">
   <soapenv:Header/>
   <soapenv:Body>
      <ship:calculateDate>
         <comuna>68</comuna>
         <skus>
            <!--1 to 20 repetitions:-->
            <sku>
               <partNumber>664860001</partNumber>
               <quantity>1</quantity>
            </sku>
         </skus>
         <!--Optional:-->
         <orderId></orderId>
      </ship:calculateDate>
   </soapenv:Body>
</soapenv:Envelope>

1 个答案:

答案 0 :(得分:0)

您的第一张图片中有一条提示:服务器在其Content-Type标题中表示内容是使用IBM 284 EBCDIC代码页编码的,这似乎是一种古老的西班牙语编码方式 - 语言文本。您的终端可能使用ASCII或UTF-8。

大多数系统都有iconv命令,可以在字符集之间进行转换。例如,要将IBM 284转换为UTF-8:

curl -X POST ... | iconv -f ibm284 -t utf-8

或者,您当然可以尝试找出服务器首先使用EBCDIC的原因。