我是一個試圖用wget測試web服務的新手,以更好地理解它是如何工作的。wget,webservice和SOAP
目前,我有一個bash腳本看起來像這樣:
#!/bin/bash
REQUEST="<?xml version=\"1.0\" ?><S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns2=\"http://schema.thecompany.se/header/v1\" xmlns:ns3=\"http://messages.thecompany.se/theServicePath/theService/v1\"><S:Body><ns3:theRequest><ns2:identity>1234567</ns2:identity></ns3:theRequest></S:Body></S:Envelope>"
MY_FILE="/tmp/myfile.xml"
echo $REQUEST > $MY_FILE
/usr/bin/wget -O - --no-cache -dv --http-user="theDomain\theUser" --http-password="aPassword" \
--post-file=$MY_FILE \
--header="SOAPAction: \"http://xmlns.thecompany.com/path/theService/theRequest\"" \
--header="Content-Type: text/xml; charset=utf-8;" \
--auth-no-challenge \
--no-check-certificate \
https://service.thecompany.com/path/theServicePath/theService_v1.svc/basic
從我已閱讀,SOAPAction域是強制性的HTTP上的SOAP,但可能是「」,因爲HTTP請求的URI已經提供了SOAP消息的意圖。
這是推薦的方法,有SOAPAction:「」,而不是像我所做的那樣在兩個地方提供URI?
如果SOAPAction被完全指定,我的代碼是否錯誤? SOAPAction URI應該與HTTP請求URI相同嗎?
在我看到的例子中,名稱空間(xmlns :)的列表比請求中使用的多。例如。我經常看到xmlns:ns3 =「http://schemas.microsoft.com/2003/10/Serialization/」,但從不在請求中使用ns3。爲什麼這樣做?
此外,我無法讓腳本工作。請求發佈後,響應爲403 FORBIDDEN。
該腳本的問題是當請求發佈時,響應是403 FORBIDDEN。添加反斜槓並沒有幫助。我主要關心的是要了解上述問題:-) – buzztr