Need Sample code of cunsuming /itg/ppmservices/DemandService (HP Demand Management) in WCF

Asked By Vijendra Patil
07-Nov-09 10:44 AM
Earn up to 0 extra points for answering this tough question.

Hi,

I am trying to consume JAVA AXIS 2 web service ( /itg/ppmservices/DemandService (HP Demand Management) in WCF. But i am getting exception. Since this web service is using WSE 3 and with WCF the support for WSE is not provided, i ma not able to access any of the web methods of that web service.

 

If anybody is having sample code then please do tell me.

  What is the error you get?

[)ia6l0 iii replied to Vijendra Patil
07-Nov-09 12:18 PM
The most probable error would be the failure to map the WSE properties from the policy file to the WCF bindings. 

MSDN article here outlines how to interopate your WCF clients or WCF Services with WSE. Look how the SecurityBindingElement is replaced with the WSEHttpBinding in the sample source code provided in that article.

Also, from another article here, this transcript below covers all that you need:
"Windows Communication Foundation (WCF) clients are wire-level compatible with Web Services Enhancements (WSE) 3.0 for Microsoft .NET services when WCF clients are configured to use the August 2004 version of the WS-Addressing specification. However, WSE 3.0 services do not support the metadata exchange (MEX) protocol, so when you use the Service Metadata Utility Tool (SvcUtil.exe) to create a WCF client class, the security settings are not applied to the generated WCF client. Therefore, you must specify the security settings that the WSE 3.0 service requires after the WCF client is generated.

You can apply these security settings by using a custom binding to take into account the WSE 3.0 service's requirements and the interoperable requirements between a WSE 3.0 service and a WCF client. These interoperability requirements include the aforementioned use of the August 2004 WS-Addressing specification and the WSE 3.0default message protection of SignBeforeEncrypt. The default message protection for WCF is SignBeforeEncryptAndEncryptSignature. "

This article can be read from here and it has sufficient code coverage.

  Need Sample code of cunsuming /itg/ppmservices/DemandService (HP Demand Management) in WCF

Vijendra Patil replied to [)ia6l0 iii
08-Nov-09 12:31 AM

I’m using a service that is using username token authentication and it’s built in wse 3.0.

http://msdn2.microsoft.com/en-US/library/aa480575.aspx

 

I am trying to interop with it via wcf like so:

http://msdn2.microsoft.com/en-us/library/ms730299.aspx

 

Code Snippet

the vendor who makes the service has given me the following policy file

<policies xmlns="http://schemas.microsoft.com/wse/2005/06/policy">

  <extensions>

    <extension name="usernameOverTransportSecurity" type="Microsoft.Web.Services3.Design.UsernameOverTransportAssertion, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

    <extension name="requireActionHeader" type="Microsoft.Web.Services3.Design.RequireActionHeaderAssertion, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

  </< SPAN>extensions>

  <policy name="InsertNameHere">

    <usernameOverTransportSecurity />

    <requireActionHeader />

  </< SPAN>policy>

</< SPAN>policies>

 

 

 

However, the services are NOT on SSL they’re hosted on basic HTTP.

 

I wrote the following client to try to talk to the service

 

Code Snippet

           Console.Write("Logging in...");

 

            //Configure an anon binding so we can log in

            WseHttpBinding binding = new WseHttpBinding();

            binding.LoadPolicy("wse3policyCache.config", "InsertNameHere");

 

            LoginServiceSoapClient loginClient =

         new LoginServiceSoapClient(binding,

         new EndpointAddress("HTTP://myserver/myLoginService.asmx") );

            Guid guid = loginClient.LogIn("username", "myP4ssw0rd",true);

 

 

 

            Console.WriteLine("Logged in!");

            Console.WriteLine(" (press any key to exit) ");

            Console.ReadKey();

 

 

           

 

Now I’m stuck because it says that http isn’t valid, but if I use https it can’t find the certificate, because there isn’t one.

 

Thanks,

  Need Sample code of cunsuming /itg/ppmservices/DemandService (HP Demand Management) in WCF

Vijendra Patil replied to [)ia6l0 iii
08-Nov-09 07:55 AM

Glad for your reply.

 

I am getting error as "Scheme http doesnt supported"

Actually I am using ClearUserNameBinding (code available on internet) for this issue. But the thing here is, the technique which I am using is like HACKING. I am implementing the ISecurityCapabelity class.

WCF doesnt go well with WSE 3.0.

Create New Account