Python Forum

Full Version: how to call WCF from python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
can anybody help with the script

I don't understand how to call WCF from python running on the raspberry ?

Is this script enough to call WCF ?
from suds.client import Client

print "Connecting to Service..."
wsdl = "http://serviceurl.com/service.svc?WSDL"
client = Client(wsdl)
result = client.service.Method(variable1, variable2)
print result
What are you trying to accomplish? WCF (windows communication framework) doesn't make sense on a raspberry, since the raspberry doesn't run windows.

Also, your code deals with wsdl, which is a definition of a Soap service, which is unrelated to wcf.

So... there's three completely different things in your post. If you let us know what you're trying to accomplish, we can try to help you get there.
(Dec-19-2018, 07:06 PM)nilamo Wrote: [ -> ].

So... there's three completely different things in your post. If you let us know what you're trying to accomplish, we can try to help you get there.

Pir sensor is connected to raspberry pi. call a webservice when my PIR sensor is active. Web services created with C#

I need Python script that can call Windows Communication Foundation (WCF) service?
Oh I get it now, thanks for clarifying. As long as the service you're connecting to is available to the network, then yes that should be what you need to use.
(Dec-20-2018, 04:00 AM)nilamo Wrote: [ -> ]Oh I get it now, thanks for clarifying. As long as the service you're connecting to is available to the network, then yes that should be what you need to use.
Thanks nilamo for helping
from suds.client import Client

print ('Connecting to Service...')
wsdl = "http://serviceurl.com/services/message.asmx"
client = Client(wsdl)
result = client.service.Push_Notification(0, 1, 1, TestingPython)

print (result)
what's the Error and how to remove it
Error:
Connecting to Service... Traceback (most recent call last): File "/usr/lib/python3.5/xml/sax/expatreader.py", line 210, in feed self._parser.Parse(data, isFinal) xml.parsers.expat.ExpatError: mismatched tag: line 61, column 16 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/pi/ST/DB/test4.py", line 5, in <module> client = Client(wsdl) File "/usr/local/lib/python3.5/dist-packages/suds/client.py", line 115, in __init__ self.wsdl = reader.open(url) File "/usr/local/lib/python3.5/dist-packages/suds/reader.py", line 150, in open d = self.fn(url, self.options) File "/usr/local/lib/python3.5/dist-packages/suds/wsdl.py", line 136, in __init__ d = reader.open(url) File "/usr/local/lib/python3.5/dist-packages/suds/reader.py", line 74, in open d = self.download(url) File "/usr/local/lib/python3.5/dist-packages/suds/reader.py", line 100, in download return sax.parse(string=content) File "/usr/local/lib/python3.5/dist-packages/suds/sax/parser.py", line 133, in parse sax.parse(source) File "/usr/lib/python3.5/xml/sax/expatreader.py", line 110, in parse xmlreader.IncrementalParser.parse(self, source) File "/usr/lib/python3.5/xml/sax/xmlreader.py", line 125, in parse self.feed(buffer) File "/usr/lib/python3.5/xml/sax/expatreader.py", line 214, in feed self._err_handler.fatalError(exc) File "/usr/lib/python3.5/xml/sax/handler.py", line 38, in fatalError raise exception xml.sax._exceptions.SAXParseException: <unknown>:61:16: mismatched tag
The error is telling you that the wsdl file isn't valid xml. From a quick google search: https://stackoverflow.com/questions/5158...d-suds-0-4

Check what you're getting from the service, it might not actually be wsdl file.