To call .NET for PowerBuilder best option is to create Class Library in Visual Studio. Sign it. In project properties, Application, Assembly Information…, check “Make assembly COM-Visible”.
Sign it class library (project properties, Signing…).
In project properties, Application, Assembly Information…, check “Make assembly COM-Visible”.
Optional, add these attributes to your class:
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId(“ClassLibrary1.Class1”)]
Register created DLL in command lime like:
regasm /tlb “path/to/dll/file.dll” /codebase
Use it from PowerBuilder like:
[code]
OLEObject obj
Integer li_rc
obj = CREATE OLEObject
li_rc = obj.ConnectToNewObject("ClassLibrary1.Class1")
IF li_rc < 0 THEN
DESTROY obj MessageBox("Connecting to COM Object Failed", "Error: " + String(li_rc)) Return
MessageBox("Connecting to COM Object Failed", "Error: " + String(li_rc)) Return
Return
ELSE obj.ShowMe()END IF
obj.ShowMe()
END IF
[/code]
To call some web service from this DLL you add service reference and then:
[code lang=”csharp”]
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address =
new EndpointAddress("http://web-service-url");
var client = new ServiceReference1.YourWebServiceClient(binding, address);
var b = client.YourWebServiceMethod();
[/code]
Leave a Reply