Reputation: 133
I have deployed a sas stored process as a web service . And I want to see the output of the stored process in python . I would really appreciate if someone could help me for the same.
Here is the process I have used -
The webservice created was - 'https://sasdev.wdw.disney.com:443/SASBIWS/services/abcweb.wsdl'
I think, it stores the stored process in a function which here is abc_web()
The python code I am using here is -
import urllib
import logging
from suds.client import Client
#from suds.wsse import *
import requests
import suds_requests
url = 'https://sasdev.wdw.disney.com:443/SASBIWS/services/abcweb.wsdl'
namespace = 'https://sasdev.wdw.disney.com:443/SASBIWS/services'
client = Client(url)
client.service.abc_web()
But it receive an error as :
ERROR:suds.client:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://tempuri.org/abcweb" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:abc_web/>
</ns1:Body>
</SOAP-ENV:Envelope>
WebFault: Server raised fault: 'A 'Client Authentication' type of exception occurred during execution of 'abcweb' service. The exception follows: No security context is available.'
Upvotes: 1
Views: 1323
Reputation: 188
I succefully connected to SAS Web Services with auth using the script below:
Username and password need to be customized.
from cred import username, password
from suds.client import Client
from suds.wsse import *
security = Security()
token = UsernameToken(username, password)
security.tokens.append(token)
url = 'http://srv/SASBIWS/services/folder/add?WSDL'
client = Client(url = url)
client.set_options(wsse=security)
print client
params = client.factory.create('addParameters')
params.num1 = 32452352
params.num2 = 34
print params
print client.service.add(params)
Hope this helps as it resolve the issue of authentication to SASWebServices.
Upvotes: 1
Reputation: 1449
Error code 1000 means: Specifies an invalid user name or password (the client application might want to re-prompt the user for credentials).
Source: http://support.sas.com/documentation/cdl/en/wbsvcdg/61496/HTML/default/viewer.htm#a003275627.htm
First of all, see if you can set up this WS in SoapUI with correct authentication. See the image below. In SoapUI, click on your SOAP request, and then go to properties below where you will need to enter your domain\userid as well as password. SAS supports encryption, but on the assumption that it has Basic Authentication enabled, you could keep it plain text.
You should be able to run your SOAP request in SoapUI.
In effect, it will add to the standard SOAP envelop a HEAD tag with these lines below. You can see when you open SOAP Log in SOAP UI:
<soapenv:Header><wsse:Security soapenv:mustUnderstand="1"
xmlns:wsse=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
xmlns:wsu=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd>
<wsse:UsernameToken wsu:Id="">
<wsse:Username>domain\username</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"></wsse:Nonce>
<wsu:Created>2014-10-22T15:10:21.866Z</wsu:Created></wsse:UsernameToken></wsse:Security></soapenv:Header>
Let me know here how you get on. I am sorry I can help you with Python direct, but if you get it to work in SoapUI, you can then compare SOAP requests between SoapIU and your Python client to see what Python does wrong.
P.S. If you don't like entering plain text passwords in SoapUI, you can use PROC PWENCODE to encrypt the password first and then copy paste it into SoapUI.
Upvotes: 2