我正在使用node-soap编写SOAP Node.js Web服务,但我不知道如何正确地制定响应。
我正在使用Web Connector将Webapp与QuickBooks 2013集成在一起。客户端将发出请求进行身份验证,并且我可以记录传递的参数,这样我就知道它正在被调用,但是我无法获得正确的响应。
该文档说,它期望一个字符串数组作为响应。WSDL的相关部分如下所示:
<s:element name="authenticateResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="authenticateResult" type="tns:ArrayOfString" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfString">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string" />
</s:sequence>
</s:complexType>
<wsdl:message name="authenticateSoapOut">
<wsdl:part name="parameters" element="tns:authenticateResponse" />
</wsdl:message>
<wsdl:operation name="authenticate">
<wsdl:input message="tns:authenticateSoapIn" />
<wsdl:output message="tns:authenticateSoapOut" />
</wsdl:operation>
<wsdl:operation name="authenticate">
<soap:operation soapAction="http://developer.intuit.com/authenticate" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
Run Code Online (Sandbox Code Playgroud)
我尝试了多种配置响应对象的方法,但是不断从客户端获取错误(QuickBooks Web Connector)
我拥有的JavaScript是:
var myService = {
'QBWebConnectorSvc': {
'QBWebConnectorSvcSoap': …Run Code Online (Sandbox Code Playgroud) 我从 BigDecimal 看到一些奇怪的行为当我使用 mathContext 进行除法时,输出与直接提供比例和舍入模式进行除法时的输出不同这是我认为应该提供相同输出的示例
public static void main(String...args){
MathContext mc = new MathContext(3,RoundingMode.HALF_UP);
BigDecimal four = new BigDecimal(4);
BigDecimal three = new BigDecimal(3);
System.out.println(four.divide(three,3,RoundingMode.HALF_UP));
System.out.println(four.divide(three,mc));
}
Run Code Online (Sandbox Code Playgroud)
输出:
1.333
1.33
Run Code Online (Sandbox Code Playgroud)
使用 MathContext 时,似乎对比例进行了不同的处理。或者我不明白什么时候使用哪个。