wget,webservice和SOAP

问题描述:

我是一个试图用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。

你不解释什么是真正是你的脚本工作,但我可能已经发现在--http-user选项参数输入错误:你没有转义反斜线。你能用--http-user="theDomain\\theUser"来尝试吗?

+0

该脚本的问题是当请求发布时,响应是403 FORBIDDEN。添加反斜杠并没有帮助。我主要关心的是要了解上述问题:-) – buzztr