Wednesday, April 16, 2014

Powershell Issue: SOAP header Action was not understood. when use wsHttpBinding

Powershell Script Calling WCF Service.

Issue: SOAP header Action was not understood. when use wsHttpBinding

This can be solved if we use basicHttpBinding.

You might want to use the basicHttpBinding to get it working with a .NET 2.0 client. That binding already provides the compatibility required by older clients or other platforms. If you still decide to go with wsHttpBinding, you will have to use Microsoft WSE to create messages in the .NET 2.0 client that are compatible with the wsHttpBinding.
With Above statement from Stackoverflow that means we can run powershell in .net 4 runtime to even overcome above problem.
http://stackoverflow.com/questions/8518282/how-to-communicate-with-a-wcf-service-wshttpbinding-a-net-2-0-client


http://stackoverflow.com/questions/2094694/how-can-i-run-powershell-with-the-net-4-runtime

Simply modify (or create) $pshome\powershell.exe.config so that it contains the following:
xml version="1.0"?> 
 
     useLegacyV2RuntimeActivationPolicy="true"> 
         version="v4.0.30319"/> 
         version="v2.0.50727"/> 
     

Path where this config file must be created :C:\Windows\System32\WindowsPowerShell\v1.0\

Sample Script to call WCF Service with Powershell as client
$uri="http://localhost:59889/Service1.svc"

$proxy = New-WebServiceProxy -Uri $URI -Class newClass1 -Namespace WebService1




$proxy.GetName()
#this is where we have int as input to service and string as output. GetData below ... 
 
$proxy.GetData(5,$true)
 

No comments :