Powershell soap using New-WebServiceProxy namespace and object issue

936 views Asked by At

I'm trying to write a soap request in powershell the service is up I can request it with soapui.

After reading this and this, I don't manage to put my paramater in the ns.param object. I don't even manage to create the ns.param object.

I try to be as much exhaustive as possible if you need more information to answer I will provide it ASAP.

I want to call this method :

search   Method  ns.resultats search(string login, string password, ns.entite entite, bool entiteSpecified, ns.searchCriteria criteres, bool details, bool c...

in the IDE the auto-completion show me that critere is type of ns.param[]

enter image description here

When I try to get-Member of the the $scParam variable I have an error message :

    gm : Le champ ou la propriété «Value» du type «ns.param» ne diffère que par la casse du champ ou de la propriété «value». Le type doit être compatible avec la spécification CLS (Common 
Language Specification).
Au caractère C:\Users\edoua\Documents\test.ps1:13 : 12
$scParam | gm
            ~~
    CategoryInfo          : NotSpecified: (:) [Get-Member], ExtendedTypeSystemException
    FullyQualifiedErrorId : NotACLSComplaintProperty,Microsoft.PowerShell.Commands.GetMemberCommand

Finally I have wrote the same method with python and zeep library and when I pass this dictionnary as param it work juste fine :

    {
   'login': 'log', 
   'password': 'pass', 
   'entite': 'personne', 
   'criteres': {
      'critere': {
         'name': 'matricule', 
         'value': '001002', 
         'operator': 'eq'
         }, 
      'pageNum': 1, 
      'pageSize': 100
      }, 
      'details': True, 
      'completePath': False
      }

Finnaly the code thank you for any help :

$url = "http://localhost:8081/search/V1?WSDL"

$WS = New-WebServiceProxy -Uri $url -Namespace ns
$type = $WS.GetType().NameSpace

#Type of object
$typeSc = $type + '.searchCriteria'
$typeScParam = $type + '.param'

# create object
$sc = new-object $typeSc
$scParam = new-object $typeScParam
$scParam | gm

#all crits
$crits = @{}

#one crit
$crit = @{}
$crit["name"] = "matricule"
$crit["operator"] = "eq"
$crit["value"] = "001002"


$crits["critere"] = $crit

# trying to cast crits into sc_param but the first issue is not here 
$scParam = $crits

$sc.pageNum = 1
$sc.pageSize = 100
$sc.critere = $scParam
0

There are 0 answers