Click here to Skip to main content
15,071,729 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

All script/code is made on Visual Studio 2015. I have 3 kind of linked situation.

1. I need to access a SOAP WSDL. So, I create new python application on VS2015 and write the script to consume from WSDL and send to Azure cloud. All module can be installed using pip. But there is one module that is unable to install which is "iothub_client". So, I search on internet and found an installer of iothub_client. The default path of installation is on "C:\Python27\Lib\site-packages" which on solutions references, I add the iothub_client.pyd on References treeview. Yes the script work well and consume information from WSDL and send to IoT Hub. Perfect! Unfortunately, it only works if I run from solutions, if I run from command line or Pyton 2.7 IDLE, it will raise error of not found module of iothub_clients.pyd on site-packages. The path is already set on Envronment Varilables.

2. I try to use Console Application to consume WSDL using HTTPRequest. This part was never succeed as it return XML format of web services. Not the direct value as done on SOAPUI.

3. Change to another way of using IronPython to execute file. Yes it have same error of unable to load module that been declared on Python. My main intention using Console and IronPython is that I already have code that succeeding send data to IoT Hub. So, I just want to use python to inquiry from WSDL and pass the value to Console Application and it will do the rest.

This is script for situation 1:-
Python
#!/usr/bin/env python
#!/usr/bin/python
#!/usr/local/lib
#!/bin/env python
#! python
# ^
import random
import datetime
import hmac
import base64
import urllib2
import time
import socket
import thread
import site; site.getsitepackages()
from distutils.sysconfig import get_python_lib; print get_python_lib()
try:
    import xml.etree.cElementTree as ET
except ImportError:
    import xml.etree.ElementTree as ET
import re
from pysimplesoap.client import SoapClient
from SOAPpy import WSDL
from paho.mqtt import client as mqtt
import sys
import re
import json
import requests
import iothub_client
from iothub_client import *
from iothub_client_args import *

IoT Hub client path: C:\Python27\Lib\site-packages\iothub_client\iothub_client.pyd
Copy to Local: True

This is script for situation 2:-
- Use web reference failed
VB.NET
Private Sub WebReferenceTools()
	Dim ws As New RDMServices
	Dim objdevice = ws.GetDeviceList()
	If Not (IsNothing(objdevice)) Then
		Dim type As Type = objdevice.GetType()
		Dim properties() As PropertyInfo = type.GetProperties()
		For Each [property] As PropertyInfo In properties
			Dim trythis = GetProprtiesValue(objslavelist, [property].Attributes.GetType.FullName)
			If Not (IsNothing(trythis)) Then
				firstheaders.Add([property].Name)
				firstvalue.Add(trythis)
				Console.WriteLine("Name " & [property].Name & ", Value: " & trythis)
			End If
		Next [property]
End Sub

** Unable to get nested properties where the properties contains another class/structure. Only able to detect for string/integer only

- Use manual HTTP request failed
** Failed by mean is unable to get resultset of XML instead getting a XML format of web service structure tree from URL

This is script for situation 3:-
C#
Option Explicit On
Option Strict On
Imports System.Xml.Linq
Imports IronPython.Hosting
Imports Microsoft.Scripting.Hosting
Imports IronPython.Runtime.Types
Module Module1
    Sub Main()
        Dim py = Python.CreateEngine()
        Try
            py.ExecuteFile("PythonApplication.py")
        Catch ex As Exception
            Console.WriteLine("Oops! We couldn't execute the script because of an exception: " & ex.Message)
        End Try

        Console.ReadLine()
    End Sub

## The py script can be executed. But how to pass python data inquiry to console application back for next process?

What I have tried:

1:-
Python
#!/usr/bin/env python
#!/usr/bin/python
#!/usr/local/lib
#!/bin/env python
#! python
# ^
import random
import datetime
import hmac
import base64
import urllib2
import time
import socket
import thread
import site; site.getsitepackages()
from distutils.sysconfig import get_python_lib; print get_python_lib()
try:
    import xml.etree.cElementTree as ET
except ImportError:
    import xml.etree.ElementTree as ET
import re
from pysimplesoap.client import SoapClient
from SOAPpy import WSDL
from paho.mqtt import client as mqtt
import sys
import re
import json
import requests
import iothub_client
from iothub_client import *
from iothub_client_args import *

2:-
VB
Private Sub WebReferenceTools()
	Dim ws As New RDMServices
	Dim objdevice = ws.GetDeviceList()
	If Not (IsNothing(objdevice)) Then
		Dim type As Type = objdevice.GetType()
		Dim properties() As PropertyInfo = type.GetProperties()
		For Each [property] As PropertyInfo In properties
			Dim trythis = GetProprtiesValue(objslavelist, [property].Attributes.GetType.FullName)
			If Not (IsNothing(trythis)) Then
				firstheaders.Add([property].Name)
				firstvalue.Add(trythis)
				Console.WriteLine("Name " & [property].Name & ", Value: " & trythis)
			End If
		Next [property]
End Sub

3:-
VB
Option Explicit On
Option Strict On
Imports System.Xml.Linq
Imports IronPython.Hosting
Imports Microsoft.Scripting.Hosting
Imports IronPython.Runtime.Types
Module Module1
Sub Main()
	Dim py = Python.CreateEngine()
	Try
		py.ExecuteFile("PythonApplication.py")
	Catch ex As Exception
		Console.WriteLine("Oops! We couldn't execute the script because of an exception: " & ex.Message)
	End Try

	Console.ReadLine()
End Sub
Posted
Updated 24-Sep-16 22:20pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900