Soap messages - WSDL

Hi!

I’m new in Soap and I’m trying to connect to a Web Service and it trows me the error “Access Denied”.
What this particular web service required is some credentials to be able to use it.
I’ve manage to do in Ignition the script to get the credentials and it works fine. I use this credentials to test if it work in the program SoapUI and it gives me as a response the correct value that I’m looking for, but in Ignition gives me the “Access Denied” error, using the same credentials.

These are the WSDL I use:

In this last one, the method I want it’s called “consultarCTGActivosPorPatente”

I do the following in a button in Ignition:

from suds.client import Client
from xml.dom.minidom import parseString
client = Client(“https://fwshomo.afip.gov.ar/wsctg/services/CTGService_v3.0?wsdl”)

ConsultaCTGActivo = client.service.consultarCTGActivosPorPatente(token,sign,CUIT,patente)

Here is the full error:

Traceback (most recent call last):
File “event:actionPerformed”, line 32, in
File “C:\Users\giuli.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\suds\client.py”, line 542, in call
return client.invoke(args, kwargs)
File “C:\Users\giuli.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\suds\client.py”, line 602, in invoke
result = self.send(soapenv)
File “C:\Users\giuli.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\suds\client.py”, line 649, in send
result = self.failed(binding, e)
File “C:\Users\giuli.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\suds\client.py”, line 702, in failed
r, p = binding.get_fault(reply)
File “C:\Users\giuli.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\suds\bindings\binding.py”, line 265, in get_fault
raise WebFault(p, faultroot)
suds.WebFault: Server raised fault: ‘Acceso Denegado - El token o la firma son nulos.’

at org.python.core.PyException.doRaise(PyException.java:219)
at org.python.core.Py.makeException(Py.java:1239)
at org.python.core.Py.makeException(Py.java:1243)
at org.python.core.Py.makeException(Py.java:1247)
at suds.bindings.binding$py.get_fault$14(C:\Users\giuli\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\suds\bindings\binding.py:266)
at suds.bindings.binding$py.call_function(C:\Users\giuli\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\suds\bindings\binding.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:149)
at org.python.core.PyFunction.__call__(PyFunction.java:327)
at org.python.core.PyMethod.__call__(PyMethod.java:124)
at suds.client$py.failed$46(C:\Users\giuli\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\suds\client.py:710)
at suds.client$py.call_function(C:\Users\giuli\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\suds\client.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:166)
at org.python.core.PyFunction.__call__(PyFunction.java:338)
at org.python.core.PyMethod.__call__(PyMethod.java:139)
at suds.client$py.send$43(C:\Users\giuli\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\suds\client.py:650)
at suds.client$py.call_function(C:\Users\giuli\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\suds\client.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:149)
at org.python.core.PyFunction.__call__(PyFunction.java:327)
at org.python.core.PyMethod.__call__(PyMethod.java:124)
at suds.client$py.invoke$42(C:\Users\giuli\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\suds\client.py:608)
at suds.client$py.call_function(C:\Users\giuli\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\suds\client.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:166)
at org.python.core.PyFunction.__call__(PyFunction.java:338)
at org.python.core.PyMethod.__call__(PyMethod.java:139)
at suds.client$py.__call__$37(C:\Users\giuli\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\suds\client.py:542)
at suds.client$py.call_function(C:\Users\giuli\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\suds\client.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
at org.python.core.PyBaseCode.call(PyBaseCode.java:194)
at org.python.core.PyFunction.__call__(PyFunction.java:387)
at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:220)
at org.python.core.PyMethod.__call__(PyMethod.java:211)
at org.python.core.PyMethod.__call__(PyMethod.java:206)
at org.python.core.PyObject.invoke(PyObject.java:3555)
at org.python.core.PyInstance.instance___call__(PyInstance.java:351)
at org.python.core.PyInstance.__call__(PyInstance.java:342)
at org.python.core.PyObject.__call__(PyObject.java:387)
at org.python.core.PyObject.__call__(PyObject.java:391)
at org.python.pycode._pyx62.f$0(<event:actionPerformed>:32)
at org.python.pycode._pyx62.call_function(<event:actionPerformed>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1275)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:647)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:183)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:284)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)
at com.sun.proxy.$Proxy29.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Ignition v7.9.1 (b2017012511)
Java: Oracle Corporation 1.8.0_121

If anyone could help me on this I’ll be very much apreciated!

A quick way to get this set up is to use the Sepasoft Web Service module. SUDS is mostly deprecated and is not really supported very well. The Web Service module allows for rapid implementation of SOAP and RESTful interfaces.

You can read more here:

https://www.sepasoft.com/web-services/

The error returned says "Access denied, token or firm are null". The Client constructor requires more parameters in this case. The first parameter should be the wsdl url and then username and password:

from suds.client import Client
client = Client(wsdl_url, username="your_username", password="the_password")
1 Like

Yes, the username and password are the token and sign values. Thank you!!!

The problem is when I try to invoke a method of that client.
The structure should be the following in (xml format):

**<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" **
**xmlns:ctg="http://impl.service.wsctg.afip.gov.ar/CTGService_v2.0/">**
**   <soapenv:Header/>**
**   <soapenv:Body>**
**      <ctg:consultarCTGActivosPorPatente>**
**         <request>**
**            <auth>**
**               <token>?</token>**
**               <sign>?</sign>**
**               <cuitRepresentado>?</cuitRepresentado>**
**            </auth>**
**            <patente>?</patente>**
**         </request>**
**      </ctg:consultarCTGActivosPorPatente>**
**   </soapenv:Body>**
**</soapenv:Envelope>**

Replacing the "?" for actual values;
token=username, sign=password, cuitRepresentado=this is a personal information of the programmer that use this web service, and patente=is the license plate of a car.

When using this method, I put:

ConsultaCTGActivo = client.service.consultarCTGActivosPorPatente(username=token, password=sign,cuit=CUIT,patente=patente)
and it trows me the same error as before.

The following is a print of the client you told me

Suds ( Infrastructure/Fedorahosted-retirement - Fedora Project Wiki ) version: 0.4 GA build: R699-20100913

Service ( CTGService_v2.0 ) tns="http://impl.service.wsctg.afip.gov.ar/CTGService_v2.0/"
Prefixes (1)
ns0 = "http://impl.service.wsctg.afip.gov.ar/CTGService_v2.0/"
Ports (1):
(CTGServiceHttpSoap20Endpoint)
Methods (23):
CTGsPendientesResolucion(ctgsPendientesResolucionRequestType request, )
anularCTG(anularCTGRequestType request, )
cambiarDestinoDestinatarioCTGRechazado(cambiarDestinoDestinatarioCTGRechazadoRequestType request, )
confirmarArribo(confirmarArriboRequestType request, )
confirmarDefinitivo(confirmarDefinitivoRequestType request, )
consultarCTG(consultarCTGRequestType request, )
consultarCTGActivosPorPatente(consultarCTGActivosPorPatenteRequestType request, )
consultarCTGExcel(consultarCTGRequestType request, )
consultarCTGRechazados(consultarCTGRechazadosRequestType request, )
consultarConstanciaCTGPDF(consultarConstanciaCTGPDFRequestType request, )
consultarCosechas(consultarCosechasRequestType request, )
consultarDetalleCTG(consultarDetalleCTGRequestType request, )
consultarEspecies(consultarEspeciesRequestType request, )
consultarEstablecimientos(consultarEstablecimientosRequestType request, )
consultarLocalidadesPorProvincia(consultarLocalidadesPorProvinciaRequestType request, )
consultarProvincias(consultarProvinciasRequestType request, )
desviarCTGAOtroDestino(desviarCTGAOtroDestinoRequestType request, )
desviarCTGAOtroEstablecimiento(desviarCTGAOtroEstablecimientoRequestType request, )
dummy()
rechazarCTG(rechazarCTGRequestType request, )
regresarAOrigenCTGRechazado(regresarAOrigenCTGRechazadoRequestType request, )
solicitarCTGDatoPendiente(solicitarCTGDatoPendienteRequestType request, )
solicitarCTGInicial(solicitarCTGInicialRequestType request, )
Types (118):
CTGConfirmadosAResolverType
CTGOtorgadosAResolverType
CTGRechazadosAResolverType
CTGsPendientesResolucionResponseType
CTGsPendientesResolucionReturnType
CTGsPendientesResolucionType
anularCTGRequestType
anularCTGType
arrayCTGsConfirmadosAResolverType
arrayCTGsOtorgadosAResolverType
arrayCTGsRechazadosAResolverType
arrayConsultarCTGActivosPorPatenteResponseType
arrayConsultarCTGRechazadosType
arrayControlType
arrayCosechasType
arrayDatosConsultarCTGType
arrayErroresType
arrayEspeciesType
arrayEstablecimientosType
arrayLocalidadesType
arrayProvinciasType
authType
cambiarDestinoDestinatarioCTGRechazadoRequestType
cambiarDestinoDestinatarioCTRRechazadoType
confirmarArriboRequestType
confirmarArriboType
confirmarDefinitivoRequestType
confirmarDefinitivoResponseType
confirmarDefinitivoReturnType
confirmarDefinitivoType
consultarCTGActivosPorPatenteRequestType
consultarCTGActivosPorPatenteResponseType
consultarCTGActivosPorPatenteReturnType
consultarCTGActivosPorPatenteType
consultarCTGDatosType
consultarCTGExcelResponseType
consultarCTGExcelReturnType
consultarCTGExcelType
consultarCTGRechazadosRequestType
consultarCTGRechazadosResponseType
consultarCTGRechazadosReturnType
consultarCTGRechazadosType
consultarCTGRequestType
consultarCTGResponseType
consultarCTGReturnType
consultarCTGType
consultarConstanciaCTGPDFRequestType
consultarConstanciaCTGPDFResponseType
consultarConstanciaCTGPDFReturnType
consultarConstanciaCTGPDFType
consultarCosechasRequestType
consultarCosechasResponseType
consultarCosechasReturnType
consultarCosechasType
consultarDetalleCTGDatosReturnType
consultarDetalleCTGRequestType
consultarDetalleCTGResponseType
consultarDetalleCTGReturnType
consultarDetalleCTGType
consultarEspeciesRequestType
consultarEspeciesResponseType
consultarEspeciesReturnType
consultarEspeciesType
consultarEstablecimientosRequestType
consultarEstablecimientosResponseType
consultarEstablecimientosReturnType
consultarEstablecimientosType
consultarLocalidadesPorProvinciaRequestType
consultarLocalidadesPorProvinciaResponseType
consultarLocalidadesPorProvinciaReturnType
consultarLocalidadesPorProvinciaType
consultarProvinciasRequestType
consultarProvinciasResponseType
consultarProvinciasReturnType
consultarProvinciasType
controlType
cosechaType
ctgsPendientesResolucionRequestType
cuitSimpleType
datosCTGType
datosCambiarDestinoDestinatarioCTGRechazadoType
datosConfirmarArriboType
datosConfirmarDefinitivoResponseType
datosConfirmarDefinitivoType
datosConsultarCTGType
datosDesviarCTGType
datosOperacionCTGResponseType
datosRechazarCTGType
datosRegresarAOrigenCTGRechazadoType
datosSolicitarCTGDatoPendienteType
datosSolicitarCTGInicialType
datosSolicitarCTGResponseType
datosSolicitarCTGType
decimalType
desviarCTGAOtroDestinoRequestType
desviarCTGAOtroDestinoType
desviarCTGAOtroEstablecimientoRequestType
desviarCTGAOtroEstablecimientoType
detalleConsultaCTGActivoType
detalleConsultaCTGRechazadoType
dummyResponseType
dummyReturnType
especieType
localidadType
operacionCTGResponseType
operacionCTGReturnType
provinciaType
rechazarCTGRequestType
rechazarCTGType
regresarAOrigenCTGRechazadoRequestType
regresarAOrigenCTGRechazadoType
solicitarCTGDatoPendienteRequestType
solicitarCTGDatoPendienteResponseType
solicitarCTGDatoPendienteType
solicitarCTGInicialRequestType
solicitarCTGInicialResponseType
solicitarCTGInicialType
solicitarCTGReturnType

I need to use the consultarCTGActivosPorPatente(consultarCTGActivosPorPatenteRequestType request, ) method.

How should I use it ?

request = client.factory.create('consultarCTGActivosPorPatenteRequestType')

1 Like

I’ve managed to make it work!!
Thanks for everything.

Care to share your solution? :wink:

This is the script I use in a button to generate it:

import sys, logging
from suds.client import Client
from xml.dom.minidom import parseString

  • Make a call to the service and create the type of parameter needed to send it.
    client = Client(‘https://fwshomo.afip.gov.ar/wsctg/services/CTGService_v3.0?wsdl’)
    req = client.factory.create(‘consultarCTGActivosPorPatenteRequestType’)

  • It require a sub Type “authType” and an integer parameter “license plate”
    auth = client.factory.create(‘authType’)
    auth[‘token’] = token
    auth[‘sign’] = sign
    auth[‘cuitRepresentado’] = Int8Value

  • I pass the sub type “auth” data and the license plate
    req[‘auth’] = auth
    req[‘patente’] = stringLicensePlate

  • Call the service passing it the parameter type “consultarCTGActivosPorPatenteRequestType” created before
    result = client.service.consultarCTGActivosPorPatente(request=req)

And that’s it!
Print the response in an area text or you can do whatever you need with it.

Hope it helps!

2 Likes