SOAPMethod and Parameter

This is a sample of a SOAPRequest I have to do:

<?xml version="1.0" ?> <soapenv:Envelope xmlns:ser="http://xxx" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header> <ser:UserTokenHeader> <ser:IdUtente>005</ser:IdUtente> </ser:UserTokenHeader> <ser:ConsumerTokenHeader> <!--Optional:--> <ser:Token>F547FE5FEA81E6DB4E6CC3D4E693DC49B75740E8F01307F6C881D4371B33C1201C063EB165C0292C6E8DE9C17010EB009AB08CBECD6D9D0D1CDF493DFD015C8E</ser:Token> </ser:ConsumerTokenHeader> </soapenv:Header> <soapenv:Body> <ser:RicercaAssistiti> <!--Optional:--> <ser:req> <!--Optional:--> <ser:RicercaPerNominativo> <!--Optional:--> <ser:Nominativo> <!--Optional:--> <ser:Nome>John</ser:Nome> <!--Optional:--> <ser:Cognome>Doe</ser:Cognome> </ser:Nominativo> <ser:RicercaParziale>false</ser:RicercaParziale> </ser:RicercaPerNominativo> <!--Optional:--> <ser:RicercaPerCodiceFiscale> <!--Optional:--> <ser:CodiceFiscale/> </ser:RicercaPerCodiceFiscale> <!--Optional:--> <ser:RicercaPerCodiceSSN> <!--Optional:--> <ser:CodiceSSN/> </ser:RicercaPerCodiceSSN> </ser:req> </ser:RicercaAssistiti> </soapenv:Body> </soapenv:Envelope>

This is a sample code used:

[code] Dim sm As SOAPMethod
Dim sr As SOAPResult

Dim Address as String = “http://…?wsdl”

sm = New SOAPMethod(Address)

sm.Parameter(“IdUtente”) = “101”
sm.Parameter(“Token”) = “93A898907B82D06666090AC5EC01A59392B49B5778C974AB1CFE5FC3B18753791D872CD6A840B5BF74594830B58F5440776F983F8F0FD57B7E2FBED3A49C9897”

sm.Parameter(“Nome”) = “John”
sm.Parameter(“Cognome”) = “Doe”

sr = sm.Invoke(“RicercaAssistiti”)[/code]

Running code, this is the error:
An exception of class SOAPException was not handled. The application must shut down.
Exception Message: Incorrect parameters

But calling method with other SOAP tool, everything works fine.

I also have some questions:

  1. How can I set a parameter with SOAPMethod.Parameter(“NodeName”) if my xml request structure is indented or/and I can have same NodeName in different tree?
  2. As in point 1., ho can I read with SOAPResult.Result (“NodeName”) if my xml response structure is indented or/and I can have same NodeName in different tree?

you cannot use soapmethod for complex parameters
xojo (and realstudio and realbasic) dont handle complex parameters or sequences in soap
you need to handle them yourself, or use monkeybread tool (some €999 …)

you must use http(secure)socket .setpostrequest with the parameters you build with a string
then http(secure)socket.post and get the result.

there are other threads in this forum about this non-sense
almost all soap request today use complex parameters
xojo soap methods are just toys to make a demo but not go further.

[quote=146049:@jean-yves pochez]you cannot use soapmethod for complex parameters
xojo (and realstudio and realbasic) dont handle complex parameters or sequences in soap
you need to handle them yourself, or use monkeybread tool (some €999 …)

you must use http(secure)socket .setpostrequest with the parameters you build with a string
then http(secure)socket.post and get the result.

there are other threads in this forum about this non-sense
almost all soap request today use complex parameters
xojo soap methods are just toys to make a demo but not go further.[/quote]

Thanks jean

I’m trying to handle parameters myself.

[code]
Dim Address as String = “http://…”

Dim s as New HTTPSocket

s.SetRequestContent(Request, ContentType)
s.Post(Address)[/code]

If request is a string with the Xml request, what I can use as “ContentType”?

SOLVED

s.SetRequestContent(Request, "text/xml") s.Post(Address, Response)

where Response is a folderitem in which code will save the server response

you can also use response = s.post( address)
and you get the xml string direcly into response.

Thanks. I saw.

Hi Pietro

i am lost on this
how you send the parameters
can you put i litter example

9 months is a lot of time for my mind, but i think (hope) this can help you.

[code]Function SOAPRequest(Url as String, Request as XmlDocument) As XmlDocument
Dim Result as XmlDocument

If Uppercase(Left(Url, 5)) = “HTTP:” Then

Dim s as New HTTPSocket
s.SetRequestContent(Request.ToString, "text/xml")

Try
  Result = New XmlDocument(s.Post(Url, App.SOAPTimeout))
Catch err as XmlException
  GoTo Response
End Try

End If

If Uppercase(Left(Url, 6)) = “HTTPS:” Then

Dim s as New HTTPSecureSocket
s.SetRequestContent(Request.ToString, "text/xml")

Try
  Result = New XmlDocument(s.Post(Url, App.SOAPTimeout))
Catch err as XmlException
  GoTo Response
End Try

End If

Response:

Return Result
End Function
[/code]

Thanks

Hi
Can I please know if there are different methods/requests in wsdl , how do I call specific request/method through HTTPSocket?

Thanks