views:

39

answers:

1

I am attempting to call a web service from a powershell script.

I am not the author of the web service, nor do I know much about web services. (I'm only ramping up in PowerShell, as well.)

The vendor of the web software has provided me with a .wsdl file. I ran wsdl.exe against it, then csc.exe against the .cs file that was generated, in order to produce proxy .dll files.

In my powershell script, I am instantiating an object, setting its url property and attempting to call one of the methods:

    [Reflection.Assembly]::LoadFrom("$ProxyDllPath\VendorProxy.dll")
    $myVar = new-object VendorObject
    $myVar.url = "http://servername/serverdirectory/serverfile.asmx"
    $myStuff = $myVar.GetStuff()

When I execute this, I get the exception:

Exception calling "GetStuff" with "0" argument(s): "Server did not recognize the value of HTTP Header SOAPAction: ."
At C:\users\xxx\desktop\xxx.ps1:56 char:55
+     $myStuff = $myVar.GetStuff<<<< ()
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

I have taken a network capture of my call and see:

POST /serverdirectory/serverfile.asmx HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.4927)
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Authorization: NTLM TlRMTVNTUAABAAAAt4II4gAAAAAAAAAAAAAAAAAAAAAGAbAdAAAADw==
Host: servername
Content-Length: 0

The WSDL description for this webservice is:

<wsdl:operation name="GetStuff">
  <soap:operation soapAction="" style="document" />
  <wsdl:input>
    <soap:body use="literal" />
  </wsdl:input>
  <wsdl:output>
    <soap:body use="literal" />
  </wsdl:output>
</wsdl:operation>

I'm afraid that I don't really understand the exception; as I said, web services is not an area where I claim competence.

How can I determine the soap action the server requires, and how do I configure my $myVar to use that soap action?

A: 

Normally the "soapAction" will have the method name qualified with the namespace (like "http://tempuri.org/GetStuff" ). You might need to check your asmx service.

If you are running PowerShell V2 (which you should be if you are able to) you could try building your proxy with New-WebServiceProxy.

$MyProxy = New-WebServiceProxy -Uri 'http://servername/serverdirectory/serverfile.asmx' -Namespace 'MyService'
Steven Murawski