我正在尝试使用Classic ASP连接到网络服务。我使用的方法FindCompanies ...但它给出了以下错误,对如何排序感到困惑请帮助
<?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>
我的ASP代码低于
<%
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
%>
答案 0 :(得分:3)
根据你给出的asmx link,wsdl打印出一个演示请求(只需在浏览器中打开!)
所以我认为你的请求错过了一些参数/有一些错误的标签/结构!发送此生成的演示请求
<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>
确实给了我一个结果!
<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>
答案 1 :(得分:2)
我也遇到过这个问题。似乎<CompanyName>training</CompanyName>
中提供的值与登录Connectwise时使用的公司名称/ ID不同。如果它是相同的,请确保它是您在创建Integrator Login时登录的那个,因为我相信它们在那时被捆绑在一起。
答案 2 :(得分:0)
作为猜测我会说问题的一部分是 OrderBy ,限制和跳过字段似乎没有正确值。即。
OrderBy 应该是列的名称
limit 应为数字
skip 应为数字
(这当然只是猜测,我不知道API是如何工作的!)
错误基本上是说服务找不到变量或者没有正确初始化(对象引用没有设置为对象的实例)。
答案 3 :(得分:0)
阅读故障信息。这显然是服务中的异常。该服务已抛出NullReferenceException
。
如果这是由于你传递的参数,那么仍然服务中的一个错误 - 应该在服务操作开始之前检查参数。