从 bash 脚本发布肥皂信封

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14198986/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 04:11:46  来源:igfitidea点击:

Post soap envelope from bash script

linuxbashsoap

提问by Vince Lowe

How would I post the following soap envelope via a bash script.

我将如何通过 bash 脚本发布以下肥皂信封。

In PHP I would post using cURL but don't know how to translate into bash?

在 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>

If possible I would also like to detect the response, which should be:

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

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>

回答by BeniBela

Perhaps like this?

也许像这样?

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

回答by Olivier Dulac

to post:

发布:

cat file | curl ...

but to retrieve the result, and act according to it, embed it all in a expectscript.

但是要检索结果并根据它采取行动,请将其全部嵌入到expect脚本中。