Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Testing Web Services + XML

$
0
0

Hello,

Beginer in powershell.. I'm just trying to send a XML parameter to a web service and getting an error...

Is it possible ??

Script:

#Web Service
$Uri = "http://siteweb/webservice.svc?WSDL"

#Path Xml
$XmlPath = "C:\xml\test2.xml"

#Xml parameters
$Xml = new-object System.Xml.XmlDocument
$Xml = [xml](get-content C:\xml\test2.xml)

#Web Service
$WebService = New-WebServiceProxy -Uri $Uri
$Response = $WebService.GetTopOrderedProducts($Xml)
$Response

Error :

Cannot convert argument "request", with value: "System.Xml.XmlDocument", for "GetTopOrderedProducts" to type 
"Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1ices_MarketingService_svc_WSDL.GetTopOrderedProductsRequest": "Cannot convert the 
"System.Xml.XmlDocument" value of type "System.Xml.XmlDocument" to type 
"Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1ices_MarketingService_svc_WSDL.GetTopOrderedProductsRequest"."
At D:\Exploit\WebServices\test.ps1:14 char:1
+ $Response = $WebService.GetTopOrderedProducts($Xml)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument

If anyone can help me... thank you !!

Jeremy



Viewing all articles
Browse latest Browse all 21975

Trending Articles