Reputation: 5417
I am trying to connect to a webservice using Classic ASP. I am using the method FindCompanies... but its giving following error, confused on how to sort it please help
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at App.Apis.v_1_5.CompanyApi.FindCompanies(ApiCredentials credentials, String conditions, String orderBy, Nullable`1 limit, Nullable`1 skip)
--- End of inner exception stack trace ---
</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
My ASP code is below
<%
msURL = "https://myconnectwise.net/v4_6_release/apis/1.5/CompanyApi.asmx"
'set up xmlhttp to checkout server
Dim oRequest
Set oRequest = Server.CreateObject("MSXML2.ServerXMLHTTP")
'setting this option will allow ServerXMLHTTP to ignore the certificate errors it encounters.
oRequest.setOption(2) = SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
' resolve, connect, send, receive - in milliseconds
oRequest.setTimeouts 10000, 10000, 10000, 10000
msSOAP = "<?xml version=""1.0"" encoding=""utf-8"" ?>"
msSOAP = msSOAP & "<s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/"">"
msSOAP = msSOAP & "<s:Body>"
msSOAP = msSOAP & "<FindCompanies xmlns=""http://connectwise.com/FindCompanies"">"
msSOAP = msSOAP & "<CompanyName>training</CompanyName>"
msSOAP = msSOAP & "<IntegrationLoginId>xxx</IntegrationLoginId>"
msSOAP = msSOAP & "<IntegratorPassword>xxx</IntegratorPassword>"
msSOAP = msSOAP & "<Conditions>CompanyName like ""Connect*"" and City = ""new jersey""</Conditions>"
msSOAP = msSOAP & " <orderBy>string</orderBy>"
msSOAP = msSOAP & " <limit>int</limit>"
msSOAP = msSOAP & " <skip>int</skip>"
msSOAP = msSOAP & "</FindCompanies>"
msSOAP = msSOAP & "</s:Body>"
msSOAP = msSOAP & "</s:Envelope>"
oRequest.Open "POST", msURL, False
oRequest.setRequestHeader "Content-Type", "text/xml"
oRequest.setRequestHeader "SOAPAction", "http://connectwise.com/FindCompanies"
oRequest.send msSOAP
Response.Write oRequest.responseText
%>
Upvotes: 1
Views: 3949
Reputation: 103
I have run into this issue as well. It seems the value provided in <CompanyName>training</CompanyName>
is not the same company name/id you use when logging into Connectwise. If it is the same make sure it is the one you logged in with when you created the Integrator Login as I believe they get tied together at that point.
Upvotes: 2
Reputation: 161831
Read the fault message. It is clearly an exception in the service. The service has thrown a NullReferenceException
.
If this is due to the parameters you are passing, then it is still a bug in the service - the parameters should have been checked before the service operation began.
Upvotes: 0
Reputation: 3010
As a guess I'd say part of the problem is the OrderBy, limit and skip fields don't appear to have correct values. i.e.
OrderBy should be the name of a column
limit should be a number
skip should be a number
(This is of course just a guess, I don't know how the API works!)
The error is basically saying that the service can't find a variable or it hasn't been initialised correctly (Object reference not set to instance of an object).
Upvotes: 0
Reputation: 8359
According to your given asmx link the wsdl prints out a demo request (just open in browser!)
So I think your request misses some parameters/has some wrong tags/structure! Sending in this generated demo request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:con="http://connectwise.com">
<soapenv:Header/>
<soapenv:Body>
<con:FindCompanies>
<!--Optional:-->
<con:credentials>
<!--Optional:-->
<con:CompanyId>asdf</con:CompanyId>
<con:ContactId>123</con:ContactId>
<!--Optional:-->
<con:IntegratorLoginId>asdf</con:IntegratorLoginId>
<!--Optional:-->
<con:IntegratorPassword>asdf</con:IntegratorPassword>
<con:PortalConfigId>123</con:PortalConfigId>
<!--Optional:-->
<con:MachineId>asdf</con:MachineId>
</con:credentials>
<!--Optional:-->
<con:conditions>asdf</con:conditions>
<!--Optional:-->
<con:orderBy>asdf</con:orderBy>
<con:limit>123</con:limit>
<con:skip>123</con:skip>
</con:FindCompanies>
</soapenv:Body>
</soapenv:Envelope>
did give me a result!
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Cannot find company in connectwise config.xml: asdf</faultstring>
<faultactor>PSA</faultactor>
<detail>
<text>Cannot find company in connectwise config.xml: asdf</text>
<type>CompanyNotFoundError</type>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Upvotes: 3