[IronPython] SOAPAction header

O'Leary, Jim Jim.O'Leary at vancouver.ca
Thu Sep 11 16:33:34 CEST 2008


I'm pasting the vb.NET code.
 
--------------------------vb.NET code
BEGINS-------------------------------------
Dim aWebService As New ws.lists.lists' Web service
Dim myCredentials As New System.Net.NetworkCredential
myCredentials = System.Net.CredentialCache.DefaultCredentials
aWebService.Credentials = myCredentials

aXMLnode = aWebService.GetListItems(args)
--------------------------vb.NET code
ENDS--------------------------------------
 
The reason I want to do it in IronPython is to see how it can be done if
you do not use the GUI that Visual Studio provides for connecting a web
service provider and consumer. I think it will work if I can add the
SOAPAction header, but how do I do that? If I write:
 
request =
HttpWebRequest.Create('http://myWebServer/ims/_vti_bin/Lists.asmx')
 
...there is no
 
request.SOAPAction = "GetListItems"
 
...Neither is there a
 
request.SetHeader("SOAPAction", "GetListItems")


Jim 




 

________________________________

From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Miha Valencic
Sent: Wednesday, September 10, 2008 9:44 PM
To: Discussion of IronPython
Subject: Re: [IronPython] SOAPAction header


Jim, first of all, why aren't you using .NET infrastructrue to invoke
WebService? I suspect this is the reason, because you forgot to set he
HTTP header attribute, and infrastracture (are you using generated proxy
stub in VB.NET?) does this for you.

You should create you proxy by deriving from
System.ServiceModel.ClientBase<IYourInterface> for WCF clients, and for
regular clients, you should derive from
System.Web.Services.Protocols.SoapHttpClientProtocol.

wsdl.exe (or svcutil.exe) does this automatically for you. And I would
not create thos proxy classes in IPy, but would rather create a proxy in
c# (with them tools :)) and then just use this .net object to invoke my
web service from IPY like so:

clr.AddReference("MyDllWhichContainsWSProxy")
from MyNamespace import MyWSProxy

foo = MyWSProxy
foo.Url = "http://...."
result = foo.MethodX([1,2,3])

I hope I'm not missing anything...

rgds,
 Miha.

ps: If you still want to do it the hard way, just add the apropriate
SOAPAction HTTP header to your HTTP request. SOAPAction headers are
different for each method you invoke and are defined in WSDL file.


2008/9/10 O'Leary, Jim <Jim.O'Leary at vancouver.ca
<mailto:Jim.O%27Leary at vancouver.ca> >



	I am trying to access a web service on a SharePoint site using
IronPython. The web service can be accessed via a vb.NET app, but not
from IronPython.

	Sniffing the packets from both IronPython and vb.NET
transactions shows that the SOAP envelope and all headers are exactly
the same in both transactions, except for the SOAPAction header, which
is missing in the IronPython app. 

	At a certain point the server sends back the following
faultstring: 

	Unable to handle request without a valid action parameter.
Please supply a valid soap action. 

	How to you add this header? Below is my code. I am able to
authenticate, but the app chokes on the request.GetResponse() line with
500 Internal Server Error.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080911/776bc0b9/attachment.html>


More information about the Ironpython-users mailing list