Developer Q&A
Error while trying to retrieve Customer after executing LogInCompany
On login, the the session does not return any cookies and the call to get Customer returns the following error.
<requests.sessions.Session object at 0x7f1192b57a20>
b'<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">soap:Bodysoap:Faultsoap:Codesoap:Valuesoap:Sender</soap:Value></soap:Code>soap:Reason<soap:Text xml:lang="en">System.Web.Services.Protocols.SoapException: Session not found. Use LogInCompany command for create a new session.\r\n at Corrigo.Web.Services.CorrigoService.Core.ServiceExecutionContext.SoapExceptionBlock(Action action) in C:\TFS-Agent\_work\6\s\Source\BusinessObjects\Corrigo.BO.CorrigoService\Core\ServiceExecutionContext.cs:line 284\r\n at Corrigo.Web.Services.CorrigoService.Core.ServiceExecutionContext.Initialize(IServiceSession session, CorrigoNetOptions options) in C:\TFS-Agent\_work\6\s\Source\BusinessObjects\Corrigo.BO.CorrigoService\Core\ServiceExecutionContext.cs:line 40\r\n at Integration.CorrigoService.Initialize() in C:\TFS-Agent\_work\6\s\Source\Web\Services\Integration\CorrigoService.asmx.cs:line 238\r\n at Integration.CorrigoService.Retrieve(EntitySpecifier entitySpecifier, PropertySetBase propertySet) in C:\TFS-Agent\_work\6\s\Source\Web\Services\Integration\CorrigoService.asmx.cs:line 0</soap:Text></soap:Reason>soap:Nodehttp://am-ce95a.corrigo.com/wsdk/CorrigoService.asmx?wsdl</soap:Node></soap:Fault></soap:Body></soap:Envelope>'
Here is the code LogInCompany code
def login(self, user_name, password, company_name, apigee_key, apigee_secret, apigee_oauth_url, apigee_url):
"""
With that access call the login function.
Apigee calls the following Corrigo function:
ns1:LogInCompany(username: xsd:string, password: xsd:string, companyname: xsd:string)
"""
token = self.get_access_token(apigee_key, apigee_secret, apigee_oauth_url)
headers = {"Content-Type": "text/xml",
"Company": company_name,
"Authorization": "Bearer " + token}
input = f"""
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:int="http://corrigo.com/integration/">
soap:Header
int:CorrigoNetOptions
int:ImposeConcurrencyIdtrue</int:ImposeConcurrencyId>
int:UpdateLastModifiedtrue</int:UpdateLastModified>
int:CanDeleteMissingEntitytrue</int:CanDeleteMissingEntity>
int:LockOnDataRetrievalDefault</int:LockOnDataRetrieval>
</int:CorrigoNetOptions>
</soap:Header>
soap:Body
int:LogInCompany
int:username{user_name}</int:username>
int:password{password}</int:password>
int:companyname{company_name}</int:companyname>
</int:LogInCompany>
</soap:Body>
</soap:Envelope>
"""
s = requests.Session()
resp = s.post(apigee_url, headers=headers, data=input)
if resp.status_code >= 400:
raise Exception(
f'Error logging in to Apigee: Http Status: {resp.status_code} Reason: {resp.reason} Message:{resp.text}')
Return the token since it's needed for successive calls.
print('Print cookies')
print(resp.cookies)
return s, token
