I believe my issue is in understanding the ins and out of what a class or a namespace is within a wsdl.
if I use $request=New-WebServiceProxy -Uri $url and try to use a function from any Service other than IApplicationService no functions show up. I understand I should be able to use class or namespace to switch ports but I’m not having any luck. Most of the documentation on New-WebServiceProxy point to outdated public wsdl’s. Is there any documentation that uses updated public api’s? Or anyone who has experience with using new-webservice proxy and making soap calls?
If I have the following soap service http://[address]/Service1.svc?wsdl
With the following structure (trimmed down for the purpose of this forum)
-p class=“line”>-/p>
I could not get the xml pasting to work here so going rogue and replace all the carrots with dashes in the xml below.
-p class=“line”>I then use the following powershell to get to the wsdl-/p>
[pre]$url=“http://[address]/Service1.svc?wsdl”
$y=New-webServiceProxy -Uri $url
$y.ServerDetailsbyServerID(10,1)
[/pre]
I get this error:
[pre]
Method invocation failed because [Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy11caqa_corpadqa_net_Service1_svc.BasicHttpBinding_IApplicationService]
does not contain a method named ‘ServerDetailsbyServerID’.
At line:5 char:1
It only sees functions from iapplicationservice. Which makes no sense. SoapUI can crawl the entire service. Thank you. I am assuming their is something within the namespace or class functions I am missing. I’ve tried adding Iserverservice as a paramater for one then the other and both and got a similar result. I offer up that maybe I do not understand API’s that well. Thank you.thank you.
Sadly it is internal. Tried that and it get’s me “You cannot call a method on a null-valued expression.” which seems to be a little promising. Frustrating in it’s own way I got this working with
When you call New-WebServiceProxy against a wsdl with multiple interfaces, the call just creates a proxy against the first interface it finds. If you want to use other interfaces, you’ll have to declare a New-Object of the type you are actually looking to use. My typical pattern for this is this:
Note that if you are using a debugger or running the script repeatedly, you will end up with namespace collisions. So in that case, I change my pattern to NOT pass in a namespace and instead get the default (ugly) one from PowerShell and reuse that.