【问题标题】:Curl command line for consuming webServices?使用 web 服务的 curl 命令行?
【发布时间】:2010-09-10 04:27:24
【问题描述】:

你们知道我如何使用 Curl 命令行 POST SOAP 来测试 Web 服务吗?

我有一个文件 (soap.xml),其中附有所有的肥皂消息,但我似乎无法正确发布它。

谢谢!

【问题讨论】:

    标签: web-services testing curl


    【解决方案1】:

    错了。 这对我不起作用。

    对我来说,这个可行:

    curl 
    -H 'SOAPACTION: "urn:samsung.com:service:MainTVAgent2:1#CheckPIN"'   
    -X POST 
    -H 'Content-type: text/xml'   
    -d @/tmp/pinrequest.xml 
    192.168.1.5:52235/MainTVServer2/control/MainTVAgent2
    

    【讨论】:

    • 史诗!感谢您花时间发布实际的工作示例!
    【解决方案2】:
    curl -H "Content-Type: text/xml; charset=utf-8" \
    -H "SOAPAction:" \
    -d @soap.txt -X POST http://someurl
    

    【讨论】:

    • 这对我有用。但是,我需要从文件中读取soap.txt 中的值。 code schemas.xmlsoap.org/soap/envelope" xmlns:usa="xyz.com/SAFSubscriberProvision">
      soapenv:Body>
      code
    • -d @soap.txt 参数提供你想要的。
    【解决方案3】:

    对于 SOAP 1.2 Web 服务,我通常使用

    curl --header "content-type: application/soap+xml" --data @filetopost.xml http://domain/path
    

    【讨论】:

      【解决方案4】:

      如果你想要一个比终端更流畅的界面,http://hurl.it/ 很棒。

      【讨论】:

        【解决方案5】:

        发布一个字符串:

        curl -d "String to post" "http://www.example.com/target"
        

        发布文件内容:

        curl -d @soap.xml "http://www.example.com/target"
        

        【讨论】:

        • 通常这个header也是必须的:-H "Content-Type: application/soap+xml;charset=UTF-8"
        • 获取HTTP/1.1 415 Unsupported Media Type 表示内容类型标头丢失或错误。试试这里建议的方法之一(application/soap+xml 对我不起作用,但text/xml 起作用)
        • 我还必须将; action=http://tempuri.org/WhateverAction 添加到Content-Type 标题中。
        猜你喜欢
        • 1970-01-01
        • 2012-08-03
        • 2011-08-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-08-07
        相关资源
        最近更新 更多