Skip to Content
author's profile photo Former Member
Former Member

Call c# dll through web service

I have a c# web service library that has a reference to a C# class library (dll). I am trying to call web service through PowerBuilder 12.5 and i was able to do it. So i expose a method in the web service and created a web service proxy in PB and i was able to get the result from the method which is just a simple return of a string value. I tried to do the same for other method which is also exposed and in that method i am creating an instance of the c# class library. For some reason PB fails calling the method and i am assuming that it is because of the dll that web service talk to.

PowerBuilder code:

str_endpoint = "http://f.........................................................................................................................................?wsdl"

s_service1 proxy_obj

SoapConnection conn

proxy_obj = create s_service1

conn = create SoapConnection

ll_return = conn.CreateInstance(proxy_obj, "s_service1",str_endpoint)

try

ls_result = proxy_obj.getdata(1,true)

ll_selected = proxy_obj.saveestimatefile()

messagebox("The result is","File created")

catch(SoapException e)

messagebox("Error calling Web Service", e.Text)

end try

Web Service code:

public string GetData(int value)

{

return string.Format("You entered: {0}", value);

}

public string saveEstimateFile()

{

Class1 obj = new Class1(); /*Cause of the error*/

return "This is a test";

}

------------------

So in the code above, the method GetData works fine but the saveEstimateFile does not work. If i just return a string in the method, it works but as soon as the instance is created, it fails. I get the following error and i am sure that the service is not calling the library.

What am i missing here and i think its the reference in the web service causing the error?

Thanks!

PBError.png (13.0 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Apr 02, 2015 at 07:57 AM

    The error message indicates that it's the service that you're calling that is failing.

    You might try calling it from another client like SoapUI. If it fails as well there, you need to talk to the people responsible for the service to find out why it's failing.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Bruce,

      Thanks for the message. I understand the message has got something to do with the service but what i don't understand is why the method GetData is not getting failed then? If i modify SaveEstimateFile to do some addition of 2 numbers then it works fine and returns a proper result in PowerBuilder but the moment i create an instance of the class i could not call the service from PowerBuilder.

      In the meantime i tried to register the dll as COM object and access it through PowerBuilder and it worked. The code i use is

      OLEObject example

      int return_code

      example = CREATE OLEObject

      return_code = example.ConnectToNewObject("COMPB.Class1")

      example.saveToFile( )

      destroy example

      What i do not understand is i read that i can use ConnectToNewObject to access the COM object in local machine but do i need to use ConnectToRemote object to access the COM object in remote server? I am trying to understand how does the PowerBuilder know to look for the class when we say ConnectToNewObject (className)? I think that class needs to be registered somewhere to look for by PB? Could you explain it?

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.