2

I'm trying to call a java webservice from a WCF client.

The Java service uses WSE 3.0 security, so I'm using a custom binding and in the Reference.cs file of the service If I change the service contract to use protectionlevel.sign and everything is working fine.

Now the problem is I need to call this service from BizTalk. but I have no way to set the protectionlevel to sign and the calls to the service fails.

I'm trying to write a custom behavior that derives from ClientCredentials behavior and override the ApplyClientBehavior method to set the protection level like this:

public override void ApplyClientBehavior(ServiceEndpoint serviceEndpoint, System.ServiceModel.Dispatcher.ClientRuntime behavior)
{
        base.ApplyClientBehavior(serviceEndpoint, behavior);
        serviceEndpoint.Contract.ProtectionLevel = ProtectionLevel.Sign;

}

But this is not working it fails with the same error as if the proctionlevel was set to default. If I inspect the contract endpoint in debug the protection level is set to sign but it has no effect.

Then I tried to remove the protectionlevel.sign from the service contract in the reference.cs file and use the clientcredentials behavior instead and before the call to service, set the protectionlevel to sign in code like this.

Service.ServiceClient client = new Service.ServiceClient();
client.Endpoint.Contract.ProtectionLevel = System.Net.Security.ProtectionLevel.Sign;

var result = client.GetData();

And this works fine. But I can't do this in BizTalk

Anyone have a clue why above code works, but the custom endpoint behavior don't?

Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54
  • Probably not the answer you want to hear, but if you can't crowbar BizTalk to give you the behaviour you want, you might try using an intermediate (IIS hosted) WCF service as a 'wrapper' around the Java service. So BizTalk WCF Adapter -> IIS WCF Service -> Java WebService. – Nick Heppleston Aug 31 '12 at 08:17
  • 1
    "And this works fine. But I can't do this in BizTalk" <- You might also want to raise a bug with Microsoft as this doesn't appear to be expected behaviour. – Nick Heppleston Aug 31 '12 at 08:18
  • Thanks man, what you said about change the Reference.cs save my life :D – aledpardo Jan 27 '16 at 14:06

0 Answers0