cancel
Showing results for 
Search instead for 
Did you mean: 

Providing web service credentials via proxy class

Marc_Campbell
Confirmed Champ
Confirmed Champ

I've followed the SDK to create a .net proxy class ( Calling a Web Service from a Workflow Script ) to be used to call a web service to update a 3rd party system. However, I don't see anything in the proxy class to handle passing credentials to the web service nor does the SDK talk about that. I know that this particular web method requires authentication since its used to actually update that system and not just grab data. Does anyone have any advice regarding passing credentials to a web service via a proxy class? Is it as simple as just adding a this.Credentials line to the constructor of the proxy class?

Basically, I'm trying to mimic the soap security header bu would like to take advantage of a proxy class.

1 ACCEPTED ANSWER

Aki_Daiguji
Star Contributor
Star Contributor

Adding an Answer Post. Marc has decided to building the HttpWebRequest and inserting the SOAP messages manually instead of going the proxy class route.

View answer in original post

4 REPLIES 4

Aki_Daiguji
Star Contributor
Star Contributor
Hi Marc,

Here are the steps on how to use WSSE security when calling out to a web service from a Unity script, based on a step outlined in one of our past support issues:

1. Create a WCF proxy class for the service using svcutil.exe (msdn.microsoft.com/.../ms733133.aspx). Name it appropriately and import into unity as a library script.

2. Create a custom binding for using the proxy class. Use a TransportSecurityBindingElement to control how security is used. Set the MessageSecurityVersion on the security element to the appropriate WS-Security version.

3. After generating a Proxy Class, the following is an example of generating a Custom Binding. There should be other examples of this on the internet, especially around MessageSecurityVersion.

using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Security.Tokens;

TransportSecurityBindingElement security = new TransportSecurityBindingElement();
security.MessageSecurityVersion = MessageSecurityVersion.WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10;

// Various security options here, such as user name parameters:
security.EndpointSupportingTokenParameters.SignedEncrypted.Add(new UserNameSecurityTokenParameters());
Binding binding = new CustomBinding(security);

4. Call the service through the script, filling in the calling parameters and return parameters either with keywords directly from the document or with properties from workflow. I generally use the latter to allow designers to change the parameters without having to change the script.

Here is another article on how to create a proxy for WCF service: www.topwcftutorials.net/.../3-ways-generate-proxy-wcf-service.html

Marc_Campbell
Confirmed Champ
Confirmed Champ
Thanks, Aki!

I've moved away from using the proxy class for the time being, in favor of just building the HttpWebRequest object and manually inserting the SOAP message. Just so I could get things working and published to the users sooner than later. But I will certainly revisit the proxy class idea, hopefully in the near future. So I appreciate the info!

Hey Marc, 

 

Would you be able to share more about this? is it the HttpWebRequest from workflow? We are running into problems with proxy classes for the same reason and the basic authentication requirements our third party system

Aki_Daiguji
Star Contributor
Star Contributor

Adding an Answer Post. Marc has decided to building the HttpWebRequest and inserting the SOAP messages manually instead of going the proxy class route.