SOAP WSDL Generate Code

FE_ServiceBinding / FE_Ruc_Sunat

ASP AutoIt C C (Unicode) C++ C++ (Unicode) C# DataFlex Delphi Foxpro Go Java Node.js Objective-C Perl PHP Extension PowerBuilder Powershell PureBasic Python CkPython Ruby SQL Server Swift TCL VB.NET VB6 VBScript Xojo
$oXml = ObjCreate("Chilkat_9_5_0.Xml")
$oXml.Tag = "soapenv:Envelope"
$oXml.AddAttribute("xmlns:soapenv","http://schemas.xmlsoap.org/soap/envelope/")
$oXml.AddAttribute("xmlns:fes","urn:FE_Service")
$oXml.AddAttribute("xmlns:xsd","http://www.w3.org/2001/XMLSchema")
$oXml.UpdateChildContent "soapenv:Header",""
$oXml.UpdateChildContent "soapenv:Body|fes:FE_Ruc_Sunat|xsd:lcRUC","string"

; In a SOAP HTTP request, including the XML declaration (<?xml version="1.0" encoding="UTF-8"?>) in the XML body is generally not required. 
$oXml.EmitXmlDecl = False
Local $soapRequestBody = $oXml.GetXml()

Local $sEndpoint = "http://www.enlacesframework.info/wsfesunat/feosesunat.php"
Local $soapAction = "urn:FE_Servicewsdl#FE_Ruc_Sunat"
;  For SOAP requests, the standard Content-Type is usually set to "text/xml" or "application/soap+xml"
Local $sContentType = "text/xml"

$oHttp = ObjCreate("Chilkat_9_5_0.Http")

$oHttp.ClearHeaders 
$oHttp.SetRequestHeader "Content-Type",$sContentType
$oHttp.SetRequestHeader "SOAPAction",$soapAction

Local $oResp = $oHttp.PostXml($sEndpoint,$soapRequestBody,"utf-8")
If ($oHttp.LastMethodSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    ConsoleWrite("Failed to send SOAP request." & @CRLF)
    Exit
EndIf

; Get the XML response body.
$oResponseXml = ObjCreate("Chilkat_9_5_0.Xml")
$oResp.GetBodyXml($oResponseXml)

Local $iStatusCode = $oResp.StatusCode
ConsoleWrite("response status code: " & $iStatusCode & @CRLF)

; If the status code does not indicate succcess, then show the response XML,
; which probably contains error information.
If ($iStatusCode <> 200) Then
    ConsoleWrite($oResponseXml.GetXml() & @CRLF)
    Exit
EndIf

ConsoleWrite($oResponseXml.GetXml() & @CRLF)

; Parse the successful SOAP response XML.

; This is a sample of the response XML, but the namespace prefixes will be different.
; We can parse the result using "*" for the namespace prefixes (see below).

ERROR: ident expected
Local $stringExit
Request XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fes="urn:FE_Service" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soapenv:Header/>
    <soapenv:Body>
        <fes:FE_Ruc_Sunat>
            <xsd:lcRUC>string</xsd:lcRUC>
        </fes:FE_Ruc_Sunat>
    </soapenv:Body>
</soapenv:Envelope>
Response XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fes="urn:FE_Service" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soapenv:Header/>
    <soapenv:Body>
        <fes:FE_Ruc_Sunat>
            <xsd:return>true</xsd:return>
            <xsd:fe_ruc>string</xsd:fe_ruc>
            <xsd:fe_nombre>string</xsd:fe_nombre>
            <xsd:fe_numero_documento>string</xsd:fe_numero_documento>
            <xsd:fe_domicilio_fiscal>string</xsd:fe_domicilio_fiscal>
            <xsd:fe_nombre_comercial>string</xsd:fe_nombre_comercial>
            <xsd:fe_estado_contribuyente>string</xsd:fe_estado_contribuyente>
            <xsd:fe_tipo_contribuyente>string</xsd:fe_tipo_contribuyente>
            <xsd:fe_distrito>string</xsd:fe_distrito>
            <xsd:fe_provincia>string</xsd:fe_provincia>
            <xsd:fe_departamento>string</xsd:fe_departamento>
            <xsd:fe_ubigeo>string</xsd:fe_ubigeo>
            <xsd:fe_condicion_contribuyente>string</xsd:fe_condicion_contribuyente>
            <xsd:fe_telefono>string</xsd:fe_telefono>
            <xsd:fe_fecha_inscripcion>string</xsd:fe_fecha_inscripcion>
            <xsd:fe_emision_electronica>string</xsd:fe_emision_electronica>
            <xsd:fe_sistema_contabilidad>string</xsd:fe_sistema_contabilidad>
            <xsd:fe_actividad_economica>string</xsd:fe_actividad_economica>
        </fes:FE_Ruc_Sunat>
    </soapenv:Body>
</soapenv:Envelope>