1

I tried it works fine for the asmx (simple web services) but for WCf do we need to do some thing different.

Can the Same work for the WCF services as i get the error for the WCF service also. i just created the Simple WCF service in .net and tried to access. but was not successful.

Error:

$Url = "http://localhost:4637/WCFService2/Service.svc"

$webclient = new-object System.Net.WebClient

$soapMessage = @"
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
   <soap:Header/>
   <soap:Body>
      <tem:GetData>
         <!--Optional:-->
         <tem:value>hji</tem:value>
      </tem:GetData>
   </soap:Body>
</soap:Envelope>
"@
$webclient.headers.Add("SOAPAction","http://localhost:4637/WCFService2/Service.svc/GetData")
$webclient.headers.Add("Content-Type", "text/xml; charset=utf-8")

$result = ([XML]$webclient.UploadString($Url, $soapMessage))#.envelope.body.GetWeatherByPlaceNameResponse.GetWeatherByPlaceNameResult

$result
Franci Penov
  • 74,861
  • 18
  • 132
  • 169
kiran k
  • 11
  • 1
  • 3
  • It would be usefull if you can show us the actual error. My initial guess would be that the call is failing as your service expects authenticated call and your PS client code is making an unauth call. – Franci Penov Nov 17 '09 at 06:30
  • any final solution with full source code? – Kiquenet Mar 15 '13 at 10:24

1 Answers1

1

Do you really want to manually fill in the SOAP packet and send it? If not, then do a Get-Help on New-WebServiceProxy assuming you are running PowerShell 2.0. This cmdlet will create a proxy object that you can directly program against.

Keith Hill
  • 194,368
  • 42
  • 353
  • 369
  • I was able to get the Proxy usibng the New-WebServiceProxy but befor i access the methods i recquire to pass the LoginToken created from other service as a header or cookie to access the methods of the services. So my now main concern is how will now pass this authentication token (Encrtpted token) to the Service. my token looks like "LogCert=534635336bsdvshsg". For SOAP UI I just pass it as a cookie to header. – kiran k Nov 18 '09 at 13:46
  • Execute $proxy | Get-Member and see if there are any members related to setting the security token. – Keith Hill Nov 18 '09 at 16:59
  • I get the method but to get the response for the methods i need to pass the Security Token in the Header. So when I use New-WebServiceProxy how will I pass the the header. – kiran k Nov 19 '09 at 05:00
  • Content-Type: text/xml;charset=UTF-8 cookie: LoginCert=iLmD3psnE4TfB9Ln4iyRSa10yC9 Content-Length: 1812 – kiran k Nov 19 '09 at 05:02