gpt4 book ai didi

node.js - Node-Soap 无法读取未定义的属性 'description'

转载 作者:搜寻专家 更新时间:2023-10-31 23:45:19 25 4
gpt4 key购买 nike

我正在使用 node-soap 来创建服务器。尝试使用不同的 wsdls 文件并且一切正常,但是这个似乎有点复杂,因为它指向模式文件。我开始使用 SOAPUI 并确定 WSDL 和 XSD 文件是否正常,所以我通过 SOAPUI 创建了一个模拟服务器并且请求/响应在那里工作正常。所以我使用 node-soap 将它连接到我的服务器,服务器启动没有问题,但是当我发送请求时它提示解析,但我已经检查了十几次,它似乎没问题。

错误类型错误:无法读取未定义的属性“描述” 在 SAXParser.p.onopentag

WSDL

<definitions name="RpService" targetNamespace="https://www.examples.com/wsdl/HelloService.wsdl" xmlns:rp="http://www.examples.com/wsdl/HelloService.wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsoma="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:documentation>BankID BUS RP interface Version: 4.0.0</wsdl:documentation>
<wsdl:types>
<xsd:schema xmlns:rp="http://www.examples.com/wsdl/HelloService.wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://bankid.com/RpService/v4.0.0/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsoma="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.examples.com/wsdl/HelloService.wsdl" schemaLocation="file:///home/jnunesju/development/nodejs/soap-server/rpservice_v4.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="RpServicePortType_Sign">
<wsdl:part element="rp:SignRequest" name="SignRequest"/>
</wsdl:message>
<wsdl:message name="RpServicePortType_Collect">
<wsdl:part element="rp:orderRef" name="orderRef"/>
</wsdl:message>
<wsdl:message name="RpServicePortType_FileSignResponse">
<wsdl:part element="rp:FileSignResponse" name="FileSignResponse"/>
</wsdl:message>
<wsdl:message name="RpServicePortType_AuthenticateResponse">
<wsdl:part element="rp:AuthResponse" name="AuthResponse"/>
</wsdl:message>
<wsdl:message name="RpServicePortType_CollectResponse">
<wsdl:part element="rp:CollectResponse" name="CollectResponse"/>
</wsdl:message>
<wsdl:message name="RpFault">
<wsdl:part element="rp:RpFault" name="RpFault"/>
</wsdl:message>
<wsdl:message name="RpServicePortType_SignResponse">
<wsdl:part element="rp:SignResponse" name="SignResponse"/>
</wsdl:message>
<wsdl:message name="RpServicePortType_Authenticate">
<wsdl:part element="rp:AuthenticateRequest" name="AuthenticateRequest"/>
</wsdl:message>
<wsdl:message name="RpServicePortType_FileSign">
<wsdl:part element="rp:FileSignRequest" name="FileSignRequest"/>
</wsdl:message>
<wsdl:portType name="RpServicePortType">
<wsdl:operation name="Authenticate">
<wsdl:input message="tns:RpServicePortType_Authenticate"/>
<wsdl:output message="tns:RpServicePortType_AuthenticateResponse"/>
<wsdl:fault message="tns:RpFault" name="RpFault"/>
</wsdl:operation>
<wsdl:operation name="Sign">
<wsdl:input message="tns:RpServicePortType_Sign"/>
<wsdl:output message="tns:RpServicePortType_SignResponse"/>
<wsdl:fault message="tns:RpFault" name="RpFault"/>
</wsdl:operation>
<wsdl:operation name="FileSign">
<wsdl:input message="tns:RpServicePortType_FileSign"/>
<wsdl:output message="tns:RpServicePortType_FileSignResponse"/>
<wsdl:fault message="tns:RpFault" name="RpFault"/>
</wsdl:operation>
<wsdl:operation name="Collect">
<wsdl:input message="tns:RpServicePortType_Collect"/>
<wsdl:output message="tns:RpServicePortType_CollectResponse"/>
<wsdl:fault message="tns:RpFault" name="RpFault"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="RpServiceSoapBinding" type="tns:RpServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="Authenticate">
<soap:operation soapAction=""/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="RpFault">
<soap:fault name="RpFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="Sign">
<soap:operation soapAction=""/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="RpFault">
<soap:fault name="RpFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="FileSign">
<wsp:PolicyReference URI="#ForceMTOM" wsdl:required="false"/>
<soap:operation soapAction=""/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="RpFault">
<soap:fault name="RpFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="Collect">
<soap:operation soapAction=""/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="RpFault">
<soap:fault name="RpFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="RpService">
<wsdl:port binding="tns:RpServiceSoapBinding" name="RpServiceSoapPort">
<soap:address location="http://127.0.0.1:3000/bankid"/>
</wsdl:port>
</wsdl:service>
<wsp:Policy wsu:Id="ForceMTOM">
<wsoma:OptimizedMimeSerialization/>
</wsp:Policy>
</definitions>

架构

<xsd:schema targetNamespace="http://bankid.com/RpService/v4.0.0/" xmlns:tns="http://bankid.com/RpService/v4.0.0/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="PersonalNumberType">
<xsd:annotation>
<xsd:documentation>An personal number should have length 12 and contain only digits. Specific certificate policies can use 10 - 12 digits.
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{10,12}"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ProgressStatusType">
<xsd:restriction base="xsd:string">
<xsd:annotation>
<xsd:documentation>The values may be changed later.</xsd:documentation>
</xsd:annotation>
<xsd:enumeration value="OUTSTANDING_TRANSACTION"/>
<xsd:enumeration value="NO_CLIENT"/>
<xsd:enumeration value="STARTED"/>
<xsd:enumeration value="USER_SIGN"/>
<xsd:enumeration value="USER_REQ"/>
<xsd:enumeration value="COMPLETE"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="UserInfoType">
<xsd:sequence>
<xsd:element name="givenName" type="xsd:string"/>
<xsd:element name="surname" type="xsd:string"/>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="personalNumber" type="tns:PersonalNumberType"/>
<xsd:element name="notBefore" type="xsd:dateTime"/>
<xsd:element name="notAfter" type="xsd:dateTime"/>
<xsd:element name="ipAddress" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="EndUserInfoType">
<xsd:sequence>
<xsd:element name="type">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="20"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="value">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="1024"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="RequirementType">
<xsd:sequence>
<xsd:sequence>
<xsd:element maxOccurs="10" minOccurs="1" name="condition" type="tns:ConditionType"/>
</xsd:sequence>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="RequirementAlternativesType">
<xsd:sequence>
<xsd:element maxOccurs="7" minOccurs="0" name="requirement" type="tns:RequirementType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ConditionType">
<xsd:sequence>
<xsd:element name="key" type="tns:RequirementConditionNameType"/>
<xsd:element maxOccurs="20" minOccurs="1" name="value">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="1024"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="RequirementConditionNameType">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="50"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="FaultStatusType">
<xsd:restriction base="xsd:string">
<xsd:annotation>
<xsd:documentation>The values may be changed later.</xsd:documentation>
</xsd:annotation>
<xsd:enumeration value="INVALID_PARAMETERS"/>
<xsd:enumeration value="ACCESS_DENIED_RP"/>
<xsd:enumeration value="CLIENT_ERR"/>
<xsd:enumeration value="CERTIFICATE_ERR"/>
<xsd:enumeration value="RETRY"/>
<xsd:enumeration value="INTERNAL_ERROR"/>
<xsd:enumeration value="ALREADY_COLLECTED"/>
<xsd:enumeration value="EXPIRED_TRANSACTION"/>
<xsd:enumeration value="ALREADY_IN_PROGRESS"/>
<xsd:enumeration value="USER_CANCEL"/>
<xsd:enumeration value="CANCELLED"/>
<xsd:enumeration value="REQ_PRECOND"/>
<xsd:enumeration value="REQ_ERROR"/>
<xsd:enumeration value="REQ_BLOCKED"/>
<xsd:enumeration value="START_FAILED"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="AuthenticateRequestType">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="personalNumber" type="tns:PersonalNumberType"/>
<xsd:element maxOccurs="20" minOccurs="0" name="endUserInfo" type="tns:EndUserInfoType"/>
<xsd:element maxOccurs="1" minOccurs="0" name="requirementAlternatives" type="tns:RequirementAlternativesType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SignRequestType">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="personalNumber" type="tns:PersonalNumberType"/>
<xsd:element name="userVisibleData" type="xsd:string"/>
<xsd:element minOccurs="0" name="userNonVisibleData" type="xsd:string"/>
<xsd:element maxOccurs="20" minOccurs="0" name="endUserInfo" type="tns:EndUserInfoType"/>
<xsd:element maxOccurs="1" minOccurs="0" name="requirementAlternatives" type="tns:RequirementAlternativesType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="FileSignRequestType">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="personalNumber" type="tns:PersonalNumberType"/>
<xsd:element name="userVisibleData" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="userNonVisibleData" type="xsd:string"/>
<xsd:element name="fileName">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="5"/>
<xsd:maxLength value="340"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="fileContent" type="xsd:base64Binary" xmime:contentType="application/octet-stream" xmime:expectedContentTypes="application/octet-stream"/>
<xsd:element maxOccurs="20" minOccurs="0" name="endUserInfo" type="tns:EndUserInfoType"/>
<xsd:element maxOccurs="1" minOccurs="0" name="requirementAlternatives" type="tns:RequirementAlternativesType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CollectResponseType">
<xsd:sequence>
<xsd:element name="progressStatus" type="tns:ProgressStatusType"/>
<xsd:sequence minOccurs="0">
<xsd:element name="signature" type="xsd:string"/>
<xsd:element name="userInfo" type="tns:UserInfoType"/>
<xsd:element name="ocspResponse" type="xsd:string"/>
</xsd:sequence>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="RpFaultType">
<xsd:sequence>
<xsd:element name="faultStatus" type="tns:FaultStatusType"/>
<xsd:element name="detailedDescription" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="AuthenticateRequest" type="tns:AuthenticateRequestType"/>
<xsd:element name="SignRequest" type="tns:SignRequestType"/>
<xsd:element name="FileSignRequest" type="tns:FileSignRequestType"/>
<xsd:complexType name="OrderResponseType">
<xsd:sequence>
<xsd:element name="orderRef" type="xsd:string"/>
<xsd:element name="autoStartToken" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="orderRef" type="xsd:string"/>
<xsd:element name="SignResponse" type="tns:OrderResponseType"/>
<xsd:element name="AuthResponse" type="tns:OrderResponseType"/>
<xsd:element name="FileSignResponse" type="tns:OrderResponseType"/>
<xsd:element name="CollectResponse" type="tns:CollectResponseType"/>
<xsd:element name="RpFault" type="tns:RpFaultType"/>
</xsd:schema>

服务器

var soap = require('soap');
var express = require('express'),
app = express();
var service = {
RpService:{
RpServiceSoapPort:{
Sign : function(args){
var n = args.personalNumber
return {orderRef: 'test'};
}
}

}
};

var xml = require('fs').readFileSync('bankid.wsdl', 'utf8');
var server = app.listen(3000, function(){
var host = '127.0.0.1',
port = server.address().port;
});
soap.listen(server,'/bankid', service, xml)

最佳答案

在我的例子中,当 mockapi 服务在 https 上运行时,问题与自签名证书有关。 node-soap 试图从自己的服务器获取 .xsd 文件(在 wsdl 中指向)。我通过在环境变量中添加 NODE_TLS_REJECT_UNAUTHORIZED=0 来修复它。也许它会对某些人有所帮助,因为在找到原因之前我浪费了很多时间。

关于node.js - Node-Soap 无法读取未定义的属性 'description',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47078343/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com