2

I am trying to access a net.tcp endpoint from powershell. I would like to use New-WebServiceProxy for that purpose, however I am not sure if it can be done. Right now I get a

    
+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.NewWebServiceProxy 

when pointing it at the wsdl (which I have heavly hand written, so it could be that...)

1
  • Have checked google :google.com/… Am I the only person trying to do this? Commented Mar 14, 2011 at 21:53

2 Answers 2

4

You simply cannot do this. New-WebServiceProxy is not a WCF proxy, its a http soap proxy.

You could probably use a combination of svcutil.exe and Add-Type to generate the proxy on the fly on machines that have svcutil.exe installed.

A more complex example in C# that you might be able to translate to powershell is available here.

Sign up to request clarification or add additional context in comments.

Comments

4

Apparently you have been able to do this since December 22nd 2008. Christian Glessner wrote a WCF Proxy generator.

The original blog post in which he described it is here. He also posted the script in this PoshCode.org post.

I updated the code to Powershell v2. I'd suggest using that version. I talk about my version on this blog post.

If you use that code, dotsource it from another script, don't include it inline. Here is an example using my version of the code:

# My example WCF service:
# https://github.com/justaprogrammer/EchoService
. .\wcf.ps1

$wsdlImporter = Get-WsdlImporter 'http://localhost.fiddler:14232/EchoService.svc/mex'
Get-WsdlImporter 'http://localhost.fiddler:14232/EchoService.svc' -HttpGet
Get-WsdlImporter 'http://localhost.fiddler:14232/EchoService.svc?wsdl' -HttpGet 

$proxyType = Get-WcfProxyType $wsdlImporter

$endpoints = $wsdlImporter.ImportAllEndpoints();
$proxy = New-Object $proxyType($endpoints[0].Binding, $endpoints[0].Address);
$proxy = Get-WcfProxy 'http://localhost.fiddler:14232/EchoService.svc/mex'
$proxy.Echo("Justin Dearing");

Get-Help Get-WsdlImporter
Get-Help Get-WcfProxyType
Get-Help Get-WcfProxy

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.