Created
February 16, 2017 01:32
-
-
Save osvalr/165b76365ed18b9129a9596ca2976cc5 to your computer and use it in GitHub Desktop.
non-tested SUNAT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
## | |
## This code have been taken from, and isn't tested yet by myself | |
## https://codeshare.io/nQXtS | |
## https://gitter.im/msolorzano/sunat2015 | |
## | |
from suds.client import Client | |
from suds.wsse import * | |
import requests | |
import suds_requests | |
def addSecurityHeader(client, username, password): | |
security = Security() | |
userNameToken = UsernameToken(username, password) | |
timeStampToken = Timestamp(validity=600) | |
security.tokens.append(userNameToken) | |
security.tokens.append(timeStampToken) | |
client.set_options(wsse=security) | |
username = '' | |
password = '' | |
session = requests.session() | |
session.auth = (username, password) | |
WSDL_URL = 'https://www.sunat.gob.pe/ol-ti-itcpgem-sqa/billService?wsdl' | |
client = Client(WSDL_URL, faults=False, cachingpolicy=1, location=WSDL_URL, transport=suds_requests.RequestsTransport(session)) | |
addSecurityHeader(client, username, password) | |
result = client.service.methodName(Inputs) | |
print result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment