Hi all,
I would like to call WCF service from powershell. Given below is my code.
$url = "http://abc.com/abc.svc"
try {
$myService = New-WebServiceProxy -Uri $url -ErrorAction Stop -Namespace "WebServiceProxy" -Class "USZip"
$myService | Get-Member -Name TestforSUMO
$myService.definition
(This works fine so I am able access WCF methods)
$result = "false"
$resultSp = "false"
$myService.TestforSUMO("Test",[ref]$result, [ref] $resultSp)
Write $result
}
catch [System.Net.WebException]{
Write ([string]::Format("Error : {0}", $_.Exception.Message))
}
But TestforSUMO method gives Error: The request failed with HTTP status 400: Bad Request.
I am not getting what is a problem. Please help me.
Code of svc.cs
___________________
[WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
public void TestforSUMO(string InputString, ref Boolean OutputString)
{
OutputString = true;
}
In WCF config file _____________
<behaviors>
<endpointBehaviors>
<behavior name="CommercientclientAPI.Service1Behavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
What I have tried:
Did some changes in Webconfig file