从bash脚本发布肥皂信封

时间:2013-01-07 15:33:43

标签: linux bash soap

如何通过bash脚本发布以下soap信封。

在PHP中,我会发布使用cURL,但不知道如何翻译成bash?

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
  <env:Header>
    <n:Request xmlns:n="http://www.****.com/iprs/soap" env:role="http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver" env:mustUnderstand="true">UserMod</n:Request>
  </env:Header>
  <env:Body>
    <n:RequestUserMod xmlns:n="http://www.****.com/iprs/soap">
      <n:UserID>****</n:UserID>
      <n:UserData >
        <n:SystemName>****</n:SystemName>
        <n:AdminState>enabled</n:AdminState>
        <n:CategoryTypeID>****</n:CategoryTypeID>
        <n:Permissions>****</n:Permissions>
        <n:BillingProgID>****</n:BillingProgID>
        <n:DefaultGroupID>****</n:DefaultGroupID>
        <n:PrimarySiteID>****</n:PrimarySiteID>
        <n:SecondarySiteID>****</n:SecondarySiteID>
        <n:ContactInfo></n:ContactInfo>
        <n:Password>****</n:Password>
      </n:UserData>
    </n:RequestUserMod>
  </env:Body>
</env:Envelope>

如果可能,我还想检测响应,应该是:

HTTP/1.1 200 OK
Content-Type:application/soap+xml; charset="utf-8"
Content-Length:509

<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Header>
<n:Response xmlns:n="http://www.*****.com/iprs/soap" env:role="http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver" env:mustUnderstand="true">UserMod</n:Response>
</env:Header>
<env:Body>
<n:ResponseUserMod xmlns:n="http://www.*****.com/iprs/soap">
<n:StatusReport>
<n:Code>ok</n:Code>
<n:SubCode>0</n:SubCode>
</n:StatusReport>
</n:ResponseUserMod>
</env:Body>
</env:Envelope>

2 个答案:

答案 0 :(得分:2)

也许是这样的?

curl --data - --request "POST" "http://www.somesite.com" <<EOF

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
  <env:Header>
    <n:Request xmlns:n="http://www.****.com/iprs/soap" env:role="http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver" env:mustUnderstand="true">UserMod</n:Request>
  </env:Header>
  <env:Body>
    <n:RequestUserMod xmlns:n="http://www.****.com/iprs/soap">
      <n:UserID>****</n:UserID>
      <n:UserData >
        <n:SystemName>****</n:SystemName>
        <n:AdminState>enabled</n:AdminState>
        <n:CategoryTypeID>****</n:CategoryTypeID>
        <n:Permissions>****</n:Permissions>
        <n:BillingProgID>****</n:BillingProgID>
        <n:DefaultGroupID>****</n:DefaultGroupID>
        <n:PrimarySiteID>****</n:PrimarySiteID>
        <n:SecondarySiteID>****</n:SecondarySiteID>
        <n:ContactInfo></n:ContactInfo>
        <n:Password>****</n:Password>
      </n:UserData>
    </n:RequestUserMod>
  </env:Body>
</env:Envelope>

EOF

答案 1 :(得分:0)

发布:

cat file | curl ...

但要检索结果并按照它行动,请将其全部嵌入expect脚本中。