curl
とPowerShellに関する質問があります。curl SOAPリクエスト
自分のサーバー(Windows Server 2008 R2 Enterprise)にgitをインストールしましたが、PowerShell git/bin/curl
から電話しています。
$tempFile = [IO.Path]::GetTempFileName() | Rename-Item -NewName { $_ -replace 'tmp$', 'xml' } –PassThru
$soupRequestXML | Set-Content $tempFile -Encoding UTF8
cd $env:temp
$cmd = "C:\Program Files (x86)\git\bin\curl -X POST -H `'Content-type:text/xml;charset:UTF-8`' -d `@" + $tempFile.name + " "+ $soapService
Invoke-Expression $cmd
ここで、$soupRequestXML
は私の石鹸リクエストです。
問題は、PowerShellが@
文字を解析する際に問題があることです。
これはPowerShellのエラーです:私はそれがドイツ語である知っているが、私は私のものではありませんサーバー上で動作
Invoke-Expression : Die Splat-Variable "@tmpCEA7" kann nicht erweitert werden. Splat-Variablen können nicht als Teil eines Eigenschafts- oder Arrayausdrucks verwendet werden. Weisen Sie das Ergebnis des Ausdrucks einer temporären Variable zu, und führen Sie stattdessen einen Splat-Vorgang für die temporäre Variable aus.
申し訳ありません。あなたはすでに@
という文字をエスケープしようとしていますが、まだ動作していません。
私もcurl
に直接文字列を渡そうとしました:
$cmd = "C:\Program Files (x86)\git\bin\curl -X POST -H `'Content-type:text/xml;charset:UTF-8`' -d `'" + $(Get-Content $tempFile) + "`' "+ $soapService
をしかし、curl
はそれを解析するためにいくつかの問題を抱えているようですので、誰かがアイデアを持って?
curl: (6) Could not resolve host: <soapenv curl: (6) Could not resolve host: <soapenv curl: (6) Could not resolve host: <com curl: (6) Could not resolve host: <arg0>xx< curl: (6) Could not resolve host: <arg1>xxx< curl: (6) Could not resolve host: < curl: (6) Could not resolve host: <
これは私のSoapRequest XMLである:あなたのXML内の二重引用符の
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:com=\"http://host...../">
<soapenv:Header/>
<soapenv:Body>
<com:test>
<arg0>xx/arg0>
<arg1>xx</arg1>
</com:test>
</soapenv:Body>
</soapenv:Envelope>
なぜあなたは 'Invoke-WebRequest'ではなく' curl'を使用していますか? –
私はJava-DeveloperでPowershellの経験はあまりないので、また、これはPoweshell Version> 2.0でのみ動作するとも考えました。 – DaveTwoG