Jump to content

SOAP error with Winhttp


Recommended Posts

Hi, I am trying to make a SOAP client for this page: http://www.expedientes.poderjudicial.gub.uy/wsConsultaIUE.php?wsdl

They give this documentation of the webservice: http://www.expedientes.poderjudicial.gub.uy/manualWebService.pdf

So, I made a script using winhttp udf to retrieve some data using the webservice 'ConsultaIUE' in which I have to send a string like this: 148-472/2002 in an xml envelope, here is the example from the documentation:

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"

xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:consultaIUEwsdl">

<soapenv:Header/>

<soapenv:Body>

<urn:consultaIUE soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

<iue xsi:type="xsd:string">148-472/2002</iue>

</urn:consultaIUE>

</soapenv:Body>

</soapenv:Envelope>

Here is the script I made:

#include 'C:\Program Files (x86)\AutoIt3\Include\WinHttp.au3'

Global $sAddress = "www.expedientes.poderjudicial.gub.uy"

$sPostData = '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' & _
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:consultaIUEwsdl"><soapenv:Header/><soapenv:Body>' & _
'<urn:consultaIUE soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><iue xsi:type="xsd:string">148-472/2002</iue></urn:consultaIUE></soapenv:Body></soapenv:Envelope>'

Global $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5")
Global $hConnect = _WinHttpConnect($hOpen, $sAddress)
Global $hRequest = _WinHttpOpenRequest($hConnect, _
"POST", _
"/wsConsultaIUE.php", _
Default, _
Default, _
'Content-Type: text/xml')

_WinHttpSendRequest($hRequest, -1, $sPostData)
_WinHttpReceiveResponse($hRequest)

Global $sHeader, $sReturned
If _WinHttpQueryDataAvailable($hRequest) Then
$sHeader = _WinHttpQueryHeaders($hRequest)
MsgBox(64, "Header", $sHeader)
Do
$sReturned &= _WinHttpReadData($hRequest)
Until @error
ConsoleWrite($sReturned)
Else
ConsoleWriteError("!No data available." & @CRLF)
MsgBox(48, "Failure", "No data available.")
EndIf

_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

But instead of receiving a xml response with the data, I receive a 500 error code and this is printed in the console:

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><SOAP-ENV:Fault><faultcode xsi:type="xsd:string">SOAP-ENV:Client</faultcode><faultactor xsi:type="xsd:string"></faultactor><faultstring xsi:type="xsd:string">Operation &apos;&apos; is not defined in the WSDL for this service</faultstring><detail xsi:type="xsd:string"></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>

I have read other threads like but I don't know how to debug this. I appreciate any help!

Link to comment
Share on other sites

I have been reading this example in another language: http://cafeconleche.org/books/xmljava/chapters/ch03s05.html and I think that the sintax in my SOAP request is ok, except for the

<?xml version="1.0"?>

at the beginning but I tried sending with it and I get the same error. I am still puzzled, I would highly appreciate any guidance.

Link to comment
Share on other sites

Now I managed to get an answer, I was forgetting to send the header "SOAPAction" in the request.

#include 'C:\Program Files (x86)\AutoIt3\Include\WinHttp.au3'

Global $sAddress = "www.expedientes.poderjudicial.gub.uy"

$sPostData = '<?xml version="1.0"?><soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' & _
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:consultaIUEwsdl"><soapenv:Header/><soapenv:Body>' & _
'<urn:consultaIUE soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><iue xsi:type="xsd:string">148-472/2002</iue></urn:consultaIUE></soapenv:Body></soapenv:Envelope>'

Global $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5")

Global $hConnect = _WinHttpConnect($hOpen, $sAddress)

Global $hRequest = _WinHttpOpenRequest($hConnect, _
"POST", _
"/wsConsultaIUE.php", _
Default, _
Default, _
'Content-Type: application/soap+xml')

_WinHttpAddRequestHeaders($hRequest, "Name: consultaIUE")
_WinHttpAddRequestHeaders($hRequest, "Binding: consultaIUEwsdlBinding")
_WinHttpAddRequestHeaders($hRequest, "SOAPAction: urn:consultaIUEwsdl#consultaIUE")
_WinHttpAddRequestHeaders($hRequest, "Style: rpc")

_WinHttpSendRequest($hRequest, -1, $sPostData)

_WinHttpReceiveResponse($hRequest)

Global $sHeader, $sReturned

If _WinHttpQueryDataAvailable($hRequest) Then
$sHeader = _WinHttpQueryHeaders($hRequest)
MsgBox(64, "Header", $sHeader)
Do
$sReturned &= _WinHttpReadData($hRequest)
Until @error

ConsoleWrite($sReturned)
Else
ConsoleWriteError("!No data available." & @CRLF)
MsgBox(48, "Failure", "No data available.")
EndIf

_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

Nevertheless, I receive this answer:

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:consultaIUEwsdl"><SOAP-ENV:Body><consultaIUEResponse><resultado xsi:type="tns:resultado"><estado xsi:type="xsd:string">EL EXPEDIENTE NO SE ENCUENTRA EN EL SISTEMA</estado><origen xsi:type="xsd:string"></origen><expediente xsi:type="xsd:string"></expediente><caratula xsi:type="xsd:string"></caratula><abogado_actor xsi:type="xsd:string"></abogado_actor><abogado_demandante xsi:type="xsd:string"></abogado_demandante><movimientos xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:giro[0]"></movimientos></resultado></consultaIUEResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

"EL EXPEDIENTE NO SE ENCUENTRA EN EL SISTEMA" means "THE FILE WAS NOT FOUND IN THE SYSTEM" but If I search for 148-472/2002 in http://www.expedientes.poderjudicial.gub.uy/Consulta.php it appears :huh:

Is there anyone that knows about SOAP that can give me any help? If not I'll need to start again with another focus or else the deadline is going to reach me :(

Edited by Mithrandir
Link to comment
Share on other sites

  • 3 months later...

Hi

Adventurer,

I try use your code to do a personal test and don't work.

Code:

Func WS2()
Global $sAddress = "http://localhost/WebService/"

$sPostData = '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' & _
  'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' & _
  'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ' & _
  'xmlns:urn="urn:ramiws">' & _
  '<soapenv:Header/>' & _
  '<soapenv:Body>' & _
 '<urn:getTexto soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' & _
'<nome_do_cidadao type="xsd:string">Rafa</nome_do_cidadao>' & _
 '</urn:getTexto>' & _
  '</soapenv:Body>' & _
'</soapenv:Envelope>'

Global $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5")
Global $hConnect = _WinHttpConnect($hOpen, $sAddress)
Global $hRequest = _WinHttpOpenRequest($hConnect, _
"POST", _
"/server.php", _
Default, _
Default, _
'Content-Type: text/xml')

_WinHttpSendRequest($hRequest, -1, $sPostData)
_WinHttpReceiveResponse($hRequest)

Global $sHeader, $sReturned
If _WinHttpQueryDataAvailable($hRequest) Then
$sHeader = _WinHttpQueryHeaders($hRequest)
MsgBox(64, "Header", $sHeader)
Do
  $sReturned &= _WinHttpReadData($hRequest)
Until @error
ConsoleWrite($sReturned)
Else
ConsoleWriteError("!No data available." & @CRLF)
MsgBox(48, "Failure", "No data available.")
EndIf

_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)
 EndFunc;

WebService WSDL

Link to comment
Share on other sites

Hi Adventurer,

Can you help me? I try use your code to do a simple test with webservice and don't work.

Func WS2()
Global $sAddress = "http://localhost/WebService/"

$sPostData = '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' & _
  'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' & _
  'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ' & _
  'xmlns:urn="urn:ramiws">' & _
  '<soapenv:Header/>' & _
  '<soapenv:Body>' & _
 '<urn:getTexto soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' & _
'<nome_do_cidadao type="xsd:string">Rafa</nome_do_cidadao>' & _
 '</urn:getTexto>' & _
  '</soapenv:Body>' & _
'</soapenv:Envelope>'

Global $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5")
Global $hConnect = _WinHttpConnect($hOpen, $sAddress)
Global $hRequest = _WinHttpOpenRequest($hConnect, _
"POST", _
"/server.php", _
Default, _
Default, _
'Content-Type: text/xml')

_WinHttpSendRequest($hRequest, -1, $sPostData)
_WinHttpReceiveResponse($hRequest)

Global $sHeader, $sReturned
If _WinHttpQueryDataAvailable($hRequest) Then
$sHeader = _WinHttpQueryHeaders($hRequest)
MsgBox(64, "Header", $sHeader)
Do
  $sReturned &= _WinHttpReadData($hRequest)
Until @error
ConsoleWrite($sReturned)
Else
ConsoleWriteError("!No data available." & @CRLF)
MsgBox(48, "Failure", "Func WS2()
Global $sAddress = "http://localhost/WebService/"

$sPostData = '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' & _
  'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' & _
  'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ' & _
  'xmlns:urn="urn:ramiws">' & _
  '<soapenv:Header/>' & _
  '<soapenv:Body>' & _
 '<urn:getTexto soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' & _
'<nome_do_cidadao type="xsd:string">Rafa</nome_do_cidadao>' & _
 '</urn:getTexto>' & _
  '</soapenv:Body>' & _
'</soapenv:Envelope>'

Global $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5")
Global $hConnect = _WinHttpConnect($hOpen, $sAddress)
Global $hRequest = _WinHttpOpenRequest($hConnect, _
"POST", _
"/server.php", _
Default, _
Default, _
'Content-Type: text/xml')

_WinHttpSendRequest($hRequest, -1, $sPostData)
_WinHttpReceiveResponse($hRequest)

Global $sHeader, $sReturned
If _WinHttpQueryDataAvailable($hRequest) Then
$sHeader = _WinHttpQueryHeaders($hRequest)
MsgBox(64, "Header", $sHeader)
Do
  $sReturned &= _WinHttpReadData($hRequest)
Until @error
ConsoleWrite($sReturned)
Else
ConsoleWriteError("!No data available." & @CRLF)
MsgBox(48, "Failure", "No data available.")
EndIf

_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen) EndFunc;.")
EndIf

_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)
 EndFunc;

WebService

[color=#000000][font=monospace][size=3]<definitions[/size][/font][/color][color=#000000][font=monospace][size=3] xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"[/size][/font][/color][color=#000000][font=monospace][size=3] xmlns:xsd="http://www.w3.org/2001/XMLSchema"[/size][/font][/color][color=#000000][font=monospace][size=3] xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"[/size][/font][/color][color=#000000][font=monospace][size=3]xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"[/size][/font][/color][color=#000000][font=monospace][size=3] xmlns:tns="urn:ramiws"[/size][/font][/color][color=#000000][font=monospace][size=3] xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"[/size][/font][/color][color=#000000][font=monospace][size=3]xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"[/size][/font][/color][color=#000000][font=monospace][size=3] xmlns="http://schemas.xmlsoap.org/wsdl/"[/size][/font][/color][color=#000000][font=monospace][size=3] targetNamespace="urn:ramiws"[/size][/font][/color][color=#000000][font=monospace][size=3]>[/size][/font][/color][color=#000000][font=monospace][size=3][indent=1]<types>[indent=1]<xsd:schema targetNamespace="urn:ramiws">[indent=1]<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/><xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>[/indent]</xsd:schema>[/indent]</types><message name="getTextoRequest">[indent=1]<part name="nome_do_cidadao" type="xsd:string"/>[/indent]</message><message name="getTextoResponse">[indent=1]<part name="return" type="xsd:string"/>[/indent]</message><portType name="RamiWSPortType">[indent=1]<operation name="getTexto">[indent=1]<documentation>Retorna teste disponível</documentation><input message="tns:getTextoRequest"/><output message="tns:getTextoResponse"/>[/indent]</operation>[/indent]</portType><binding name="RamiWSBinding" type="tns:RamiWSPortType">[indent=1]<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><operation name="getTexto">[indent=1]<soap:operation soapAction="urn:ramiws/getTexto" style="rpc"/><input>[indent=1]<soap:body use="encoded" namespace="urn:ramiws/getTexto" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>[/indent]</input><output>[indent=1]<soap:body use="encoded" namespace="urn:ramiws/getTexto" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>[/indent]</output>[/indent]</operation>[/indent]</binding><service name="RamiWS">[indent=1]<port name="RamiWSPort" binding="tns:RamiWSBinding">[indent=1]<soap:address location="http://localhost/WebService/server.php"/>[/indent]</port>[/indent]</service>[/size][/font][/color][/indent][color=#000000][font=monospace][size=3]</definitions>[/size][/font][/color]

The response i received from AutoIt is "No data available".

Thanks for anyone can help!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...