Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to call WCF from python
#1
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
Reply
#2
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.
Reply
#3
(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?
Reply
#4
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.
Reply
#5
(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
Reply
#6
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Call pip3 from python folder build by me call pip3 from the /usr/bin Suryavarman 3 3,629 Oct-07-2019, 10:23 PM
Last Post: Suryavarman

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020