Skip to content

Instantly share code, notes, and snippets.

@EtherZa
Created May 12, 2017 10:27
Show Gist options
  • Save EtherZa/085729a77cd92f53bc5838f308f34386 to your computer and use it in GitHub Desktop.
Save EtherZa/085729a77cd92f53bc5838f308f34386 to your computer and use it in GitHub Desktop.
Generate WCF service from WSDL (URL hosted) and rewrite fields as properties
$url = "http://<url>?WSDL"
$name = "<Service Name>"
$namespace = "<Base Namespace>." + $name
$file = "$name.generated.cs"
echo "Generating service $name ($url)"
& "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\SvcUtil.exe" /t:code $url /language:C# /n:"*,$namespace" /out:$file /noConfig /syncOnly | out-null
(Get-Content $file) | Foreach-Object {$_ -replace "(?<=public [\w\.]+(?:\[\])? \w+)(;)", " { get; set; }"} | Set-Content $file
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment