Consume WCF Service using Visual Basic 6 - wcf

I would like to know how I could consume a WCF service using Visual Basic 6. I created a service and I set up to use custom validation, passing user credentials. Apparently, if I add the service, which is hosted on my local IIS as a Service Reference, I am able to call the methods in my service. To pass the credencials I use the ClientCredentials class, by setting the UserName and Password properties as shown below:
publicServiceClient.ClientCredentials.UserName.UserName = userName;
publicServiceClient.ClientCredentials.UserName.Password = password;
Some guy who will consume my service, do not have experience with C# or Visual Basic.NET, which became to a problem for consume the service, since it is not possible to add the service as a service reference in Visual Basic 6.
Is there anything I can do for help this developer, so that this guy can consume my service using Visual Basic 6? Is there some library, class or third party solution that enable me to pass the credentials for the service? I tried inspecting some calls to the service using Fidler, and the credentials that I passed (using a project that I created as client) are not passed within a header.
Please, if someone can help me I appreciate. I really would rather not change the implementation of my service or configuration.

It's hard to know from what you've described,
He could possibly use a XMLHTTP request from VB6 if you have a url for your web proxy. I don't know if that's a possibility?
That's for a simple scenario, but if you can create a Visual Studio project with Output Type set to a Class Library project,
Then the VB6 project just needs to add a reference to your publicServiceClient type library.
In his code he can then use Intellisense to get your service properties:
Something variation like this might work
Dim o As publicServiceClient.UserService
Dim usr As publicServiceClient.ClientCredentials
Set o = New publicServiceClient.UserService
Set usr = o.UserName(1)
MsgBox usr.UserName & " " & usr.Password
There is an example and some code you can download from http://www.techrepublic.com/article/create-a-proxy-to-consume-net-web-services/#
I don't know if this answers your question, but perhaps it's a helpful start?

Related

Deploying WCF Library

I am sorry in advance for the question because it should be so easy for someone who has web programming experience, but for me ...
I have created a WCF library which gets an email address, subject and body and sends email using a gmail account. I do not know how I can deploy it.
I already published it on my host using visual studio but don't know what URL should I use to call it. Can I use it directly or I have to create a WCFapplication and add the service to it then publish the WCF app?
Also, I noticed the base address in its config file is sth like: localhost/emailservice/service1 and I am not sure if I should edit it or not and how.
Your help is greatly appreciated.
Since you created a WCF library, I am assuming that you are open to host it as an IIS application or as a windows service.
Assuming that you wish to host your library as an IIS application, follow the steps mentioned in this blog to host your WCF service library.
Please note: If you intended to host your service as an IIS application, it would have been far easier for you to create a WCF service application project in Visual Studio instead of a WCF service library project.

Defining Web Service via VB.NET Code

Good Day Everyone -
I'm using VB.NET within VS2013 (Professional) and have a question about defining a Web Service binding via code.
I can successfully had a Service Reference via Solution Explorer and connect to a specified URL for the web service I'm trying to access.
What I am looking for is some direction on how to define the endpoint via code; the web service I'm hitting will be local to each facility and I need to allow a user to define the endpoint URL on the fly.
Any thoughts or insight would be appreciated.
After researching I found the problem.
When I connected to the Web Service VS stored the connection details in app.config in the folder of the project. At run time, VS compiled the app.config into .config which had to go with compiled application.
Once I did this I was able to connect without a problem to the defined WS outside of VS. Once basic connection details were present, I could successfully override the remote endpoint with whatever the user inputted.

From a WCF service how can I call a method in a third party dll as the current user not IIS\DefaultApppool

I have a requirement to write a WCF service that will be called from MS Excel using the Service Moniker from VBA code. So far that part I have figured out.
I also have impersonation working so that if I were to return the current user from a web method it will return my username and not IIS\DefaultAppPool or whatever IIS is running as...
So here is my issue. I have a third party dll "CyberArk Password Management if anyone is interested" where I create a PWD object, set some parameters and then call a method named Getpassword. Now I can call the method but I always get a authenication failure. If I dig into the logs of the CyberArk agent that I have running it seems that even though I am using Impersonation that the dll method is still being called as IIS\DefaultAppPool
Here are a few snippets...
Impersonation is turned on at the method Level
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
A call to this method returns my Domain and User name as I would expect
WindowsIdentity.GetCurrent().Name
But this line is being called as IIS\DefaultAppPool
password = PasswordSDK.GetPassword(passRequest);
I have tried doing Impersonation in Code rather than using the Annotaion, I have also tried a Impersonation object with a using bolck and nothing seems to work so here is what I am thinking.
The dll somehow does not allow me to impersonate the caller for security reasons
It may be the .NET framework not allowing this again for security reasons
I have no clue and would love some help :-)
You can self-host the application instead of using IIS to host. Then the service will be running in a process that is already running as the current user.
(If this an option)

development setup for wcf with username security on VS2010 and IIS express

Here's the end game... I need a wcf service application with username/password security over ssl. Pretty basic stuff, but I'm at my wit's end trying to make this work. I'm trying to implement the HOWTO guide from microsoft's patterns and practices as listed here:
How to: Use Username Authentication with Transport Security in WCF Calling from Windows Forms.
I've follwed each of the steps exactly... except steps 9 - 12. Those steps implement a custom authentication and authorization class. I'm having errors both with the implmentation of these custom classes and without.
First, without the custom classes... Without the custom authorization and authentication I can compile my wcf project and create the service reference in the console client application. When I run my console application it works, but when I decorate my wcf method to restrict the permissions, it appears that the client is never passing the credentials to the wcf service. If it leave the decoration off the method and step trace into the wcf method, if find that the ServiceSecurityContext.Current.PrimaryIdentity.Name is blank. I'm decorating with:
[PrincipalPermission(SecurityAction.Demand, Role = "sysadmin")]
(and yes, I've used the ASP.net configuration to create the role and the account in that role.)
Second, with the custom classes... If I include the HttpModules element as listed in step 10, I get an error stating that IIS express 7.5 doesn't do it this way any more and I need to move the configuration. With a little bit of hunting I found that I needed to move the item to . But it still complains that is can't reference the module. If I leave out the authentication module and try to just reference the authorization module, I get the same error.
I tried to include the entire web.config, but this editor didn't want to take it all. Suffice it to say that it's exactly like the msdn article except for moving the module tag.

Re-using a thirdy party web service using WCF

I have a 3rd party web service, which I intend to use from 2 different applications:
a Windows Workflow (WF) project
a website
Right now, from these 2 apps I manually add the reference to the 3rd party web service & call the required method. This means I have this proxy layer generated in 2 places.
What am looking for is a way to create (am not sure about the correct word to use, sorry guys) the 3rd party web service in one place & have the 2 applications re-use it.
Can this be achieved using WCF, something like wrapping the 3rd party web service in WCF.
Is this approach right?any help or pointers would be a great help, haven't done much service based development.
Environment: The website, the WF project resides on 2 different servers (windows 2003 R2).
Environment(development): windows 7 enterprise/vs 2010 / c#
Thanks
More detail:
Think I dint use the right words in my first query, the following is what am looking for & why I need it that way,I need to call the 3rd party web service from a new WCF service.This new WCF service will be called from other applications(winforms/WF/website) instead of calling the 3rd party service.The idea is to able to switch the 3rd party service(vendore) without changing the implementation & in one place.We use an hr-xml format for request/response & all our vendors(exisiting or future) support the hr-xml format for the industry we are in.If we use a class library, then to change vendor, we should recompile & distribute the dll correct,we dont want to do that. I am not sure about an architecture to be followed to achieve this whole functionaity.Any pointers in the right direction would be a great help.
Thanks
Your quest makes great sense indeed - and I think it should be quite easy to accomplish:
create a new class library assembly ("WebServiceClient" or whatever you want to call it)
inside that new project, do you Add Service Reference - this will create the necessary WCF proxy classes and the config file
compile that class library
From both your apps, you should be able to reference that web service client assembly, and use it - you have the code for the client side proxy only inside that common assembly, but you can use it from any number of apps.
One point to remember: you will need to copy&paste the config for the web service to the main application's config (app.config for a Winforms/console app, web.config for a website/web app) since it cannot be read directly from a class library's config file (that won't be used by .NET).
In this case, I think, WCF service will be the gr8 idea. You dont want to recombile the client applications if the vendor is changed.