Node-Soap Cannot read property 'description' of undefined - node.js

I'm using node-soap in order to create a server. Tried with different wsdls files and all worked fine but this one seems a bit more complex as it points to a schema file. I started by using SOAPUI and determine if WSDL and XSD file were ok, so I've created a mock sever through SOAPUI and requests / responses were working fine there. So I've hooked it to my server using node-soap, the server starts up no problem but when I send requests it complains about parsing but I've checked it a dozen of times and it seems to be fine.
Error
TypeError: Cannot read property 'description' of undefined
at 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>
Schema
<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>
Server
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)

In my case the issue was connected to self-signed certificate when mockapi service was ran on https. node-soap was tried to get .xsd file (which is pointed in wsdl) from own server. I fixed it by adding NODE_TLS_REJECT_UNAUTHORIZED=0 in env variables. Maybe it'll be helpful for somebody because I wasted a lot of time until I found the reason.

May be something funny with WSDL and /or SCHEMA file but by putting the schema file within the wsdl it did work for me. I understand no many companies are using SOAP but in case someone comes across this type of issue this solution might work.

I had the same problem; In my case the schemaLocation attribute was not pointing to a valid path, and node-soap was failing silently (!) before it could map definitions from the WSDL, which cause the error that you're seeing.
In my case I switched to a Unix-style relative path and everything was hunky-dory.

Related

Node Soap request to Siebel system

I am building a Node system where as per requirement wsdl from other source(Siebel) is getting consumed. Am using soap npm to build this, but while sending request to Siebel error appears like "Error: Inbound SOAP Message - Session Token is missing or invalid or has expired". Googled it out and looks like related to authentication issue, so added "client.setSecurity(new soap.WSSecurity('username', 'password'))" in the code. Final code looks like as below:
var soap = require('soap');
var url = 'http___siebel.com_xml_CustomPay_AAA Payment Service BS.WSDL';
var args = {
amount:'100',
transactionReference:'abc123',
orderId:'50',
customerId:'112211',
merchantTransactionDateTime:'22/01/2020',
RequestHeader: {serviceName:'Pay',
operation: 'Create',
reqSystemName: 'Node',
originatorID: '112205',
originatorIP: 'aa.aa.aa.aa',
hostName: 'siebelbuild'}
}
//client.addSoapHeader(RequestHeader,"","tns","http://siebel.com/xml/CustomPay")
soap.createClient(url, function(err, client) {
client.setSecurity(new soap.WSSecurity('username', '****word'))
client.Upsert1(args, function(err, result) {
console.log(result);
});
});
WSDL file looks like:
<?xml version="1.0" encoding="UTF-8" ?>
- <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsdLocal1="http://www.siebel.com/xml/XXXGovPayRequest" targetNamespace="http://siebel.com/xml/CustomPay" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsdLocal2="http://www.siebel.com/xml/XXXGovPayResponse" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://siebel.com/xml/CustomPay">
- <types>
- <xsd:schema elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://www.siebel.com/xml/XXXGovPayResponse" xmlns:xsdLocal2="http://www.siebel.com/xml/XXXGovPayResponse" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <xsd:annotation>
<xsd:documentation>Copyright (C) 2001-2004 Siebel Systems, Inc. All rights reserved. Siebel XSD Generation</xsd:documentation>
</xsd:annotation>
<xsd:element name="XXXGovPayResponse" type="xsdLocal2:XXXGovPayResponse" />
+ <xsd:complexType name="XXXGovPayResponseTopElmt">
- <xsd:sequence>
<xsd:element name="XXXGovPayResponse" maxOccurs="1" minOccurs="1" type="xsdLocal2:XXXGovPayResponse" />
</xsd:sequence>
</xsd:complexType>
- <xsd:complexType name="XXXGovPayResponse">
- <xsd:sequence>
<xsd:element name="OneOffPaymentDetailResponse" maxOccurs="unbounded" minOccurs="1" type="xsdLocal2:OneOffPaymentDetailResponse" />
</xsd:sequence>
</xsd:complexType>
- <xsd:complexType name="OneOffPaymentDetailResponse">
- <xsd:sequence>
<xsd:element name="transactionReference" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="ResponseHeader" maxOccurs="1" minOccurs="0" type="xsdLocal2:ResponseHeader" />
<xsd:element name="Response" maxOccurs="1" minOccurs="0" type="xsdLocal2:Response" />
</xsd:sequence>
</xsd:complexType>
- <xsd:complexType name="ResponseHeader">
- <xsd:sequence>
<xsd:element name="sourceObjectId" maxOccurs="1" minOccurs="0" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
- <xsd:complexType name="Response">
+ <xsd:sequence>
<xsd:element name="responseCode" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="responseMessage" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="ResponseDetails" maxOccurs="1" minOccurs="0" type="xsdLocal2:ResponseDetails" />
</xsd:sequence>
</xsd:complexType>
- <xsd:complexType name="ResponseDetails">
- <xsd:sequence>
<xsd:element name="errorCode" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="errorDescription" maxOccurs="1" minOccurs="0" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
- <xsd:schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xsdLocal1="http://www.siebel.com/xml/XXXGovPayRequest" targetNamespace="http://www.siebel.com/xml/XXXGovPayRequest" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <xsd:annotation>
<xsd:documentation>Copyright (C) 2001-2004 Siebel Systems, Inc. All rights reserved. Siebel XSD Generation</xsd:documentation>
</xsd:annotation>
<xsd:element name="XXXGovPayRequest" type="xsdLocal1:XXXGovPayRequest" />
- <xsd:complexType name="XXXGovPayRequestTopElmt">
- <xsd:sequence>
<xsd:element name="XXXGovPayRequest" maxOccurs="1" minOccurs="1" type="xsdLocal1:XXXGovPayRequest" />
</xsd:sequence>
</xsd:complexType>
- <xsd:complexType name="XXXGovPayRequest">
- <xsd:sequence>
<xsd:element name="oneOffPaymentDetailRequest" maxOccurs="1" minOccurs="1" type="xsdLocal1:oneOffPaymentDetailRequest" />
</xsd:sequence>
</xsd:complexType>
- <xsd:complexType name="oneOffPaymentDetailRequest">
- <xsd:sequence>
<xsd:element name="paymentInputs" maxOccurs="1" minOccurs="1" type="xsdLocal1:paymentInputs" />
</xsd:sequence>
</xsd:complexType>
- <xsd:complexType name="paymentInputs">
- <xsd:sequence>
<xsd:element name="acquirerResponseCode" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="acquirerResponseDescription" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="amount" maxOccurs="1" minOccurs="1" type="xsd:string" />
<xsd:element name="RequestHeader" maxOccurs="1" minOccurs="0" type="xsdLocal1:RequestHeader" />
<xsd:element name="cardScheme" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="chargeAmount" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="creditDebitIndicator" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="maskedPan" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="merchantTransactionDateTime" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="orderAmount" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="responseCode" maxOccurs="1" minOccurs="1" type="xsd:string" />
<xsd:element name="responseDescription" maxOccurs="1" minOccurs="1" type="xsd:string" />
<xsd:element name="transactionDateTime" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="authorizationCode" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="merchantId" maxOccurs="1" minOccurs="1" type="xsd:string" />
<xsd:element name="transactionReference" maxOccurs="1" minOccurs="1" type="xsd:string" />
<xsd:element name="orderId" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="customerId" maxOccurs="1" minOccurs="1" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
- <xsd:complexType name="RequestHeader">
- <xsd:sequence>
<xsd:element name="serviceName" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="operation" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="reqSystemName" maxOccurs="1" minOccurs="1" type="xsd:string" />
<xsd:element name="originatorID" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="originatorIP" maxOccurs="1" minOccurs="0" type="xsd:string" />
<xsd:element name="sourceObjectId" maxOccurs="1" minOccurs="1" type="xsd:string" />
<xsd:element name="hostName" maxOccurs="1" minOccurs="0" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
- <xsd:schema elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://siebel.com/xml/CustomPay" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.siebel.com/xml/XXXGovPayResponse" />
<xsd:import namespace="http://www.siebel.com/xml/XXXGovPayRequest" />
- <xsd:element name="Upsert1_Input">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element ref="xsdLocal1:XXXGovPayRequest" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
- <xsd:element name="Upsert1_Output">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element ref="xsdLocal2:XXXGovPayResponse" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
- <message name="Upsert1_Input">
<part name="Upsert1_Input" element="tns:Upsert1_Input" />
</message>
- <message name="Upsert1_Output">
<part name="Upsert1_Output" element="tns:Upsert1_Output" />
</message>
- <portType name="XXXPaymentServiceBS">
- <operation name="Upsert1">
<input message="tns:Upsert1_Input" />
<output message="tns:Upsert1_Output" />
</operation>
</portType>
- <binding name="XXXPaymentServiceBS" type="tns:XXXPaymentServiceBS">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <operation name="Upsert1">
<soap:operation soapAction="document/http://siebel.com/xml/CustomPay:Upsert1" />
- <input>
<soap:body use="literal" />
</input>
- <output>
<soap:body use="literal" />
</output>
</operation>
</binding>
- <service name="XXX_spcPayment_spcService_spcBS">
- <port binding="tns:XXXPaymentServiceBS" name="XXXPaymentServiceBS">
<soap:address location="http://aa.aa.bb.bb.:8080/eai_enu/start.swe?SWEExtSource=WebService&SWEExtCmd=Execute&WSSOAP=1" />
</port>
</service>
</definitions>
Also imported the wsdl in soapUI tool to check but result is same.
Could someone please help.
Depends on how the provider has setup the security. Try passing userid and password as SOAP headers. Try these soap headers
<UsernameToken>{username}</UsernameToken>
<PasswordText>{password}<PasswordText>

How to make an xsd element as Mandatory element

In the below xsd, I want to make the EDI_DC element as mandatory.I tried by using minOccurs="1" and nillable="false" but it is not working.
please suggest me any other way here to make this element as mandatory.
xsd:
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
xmlns:tns="http://TargetNamespace.com/sdg"
targetNamespace="http://www.oracle.com/ias/processconnect"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
nxsd:stream="chars"
nxsd:version="NXSD">
<xsd:element name="Root-Element">
<xsd:complexType>
<xsd:sequence maxOccurs="unbounded">
<xsd:element name="EDI_DC" nxsd:startsWith="EDI_DC" >
<xsd:complexType>
<xsd:sequence>
<xsd:element name="tabnam"
type="xsd:string"
nxsd:style="fixedLength"
nxsd:length="4"
/>
<xsd:element name="mandt"
type="xsd:string"
nxsd:style="fixedLength"
nxsd:length="3"
/>
<xsd:element name="docnum"
type="xsd:string"
nxsd:style="fixedLength"
nxsd:length="16"
/>
<xsd:element name="docrel"
type="xsd:string"
nxsd:style="fixedLength"
nxsd:length="4"
/>
<xsd:element name="EDI_DCeol"
type="xsd:string"
nxsd:style="terminated"
nxsd:terminatedBy="${eol}" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="E2EDL20" nxsd:startsWith="E2EDL20">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="segnam_ver" type="xsd:string"
nxsd:style="fixedLength"
nxsd:length="23"
/>
<xsd:element name="mandt" type="xsd:string"
nxsd:style="fixedLength"
nxsd:length="3" />
<xsd:element name="docnum" type="xsd:string"
nxsd:style="fixedLength"
nxsd:length="16" />
<xsd:element name="E2EDL20EOL" type="xsd:string"
nxsd:style="terminated"
nxsd:terminatedBy="${eol}"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

xsd restriction by value

folks, i need your help with the following.
my xml looks like this:
<Images>
<Image ImageId="1" ImageFile="a.png"/>
<Image ImageId="2" ImageFile="b.png"/>
<Image ImageId="3" ImageFile="c.png"/>
<Image ImageId="4" ImageFile="d.png"/>
<Image ImageId="5" ImageFile="e.png"/>
</Images>
<Banners>
<Banner BannerId="1" ImageId="2"/>
<Banner BannerId="43" ImageId="3"/>
<Banner BannerId="45" ImageId="4"/>
<Banner BannerId="596" ImageId="2"/>
<Banner BannerId="6" ImageId="2"/>
</Banners>
i need to create an xsd that will restrict ImageId values in Banner elements to those appearing in Images. Is it possible?
Yes; the XML schema components you need are key/keyref:
<?xml version="1.0" encoding="utf-8"?>
<!--XML Schema generated by QTAssistant/XML Schema Refactoring (XSR) Module (http://www.paschidev.com)-->
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="sample">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Images">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="Image">
<xsd:complexType>
<xsd:attribute name="ImageId" type="xsd:unsignedByte" use="required"/>
<xsd:attribute name="ImageFile" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Banners">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="Banner">
<xsd:complexType>
<xsd:attribute name="BannerId" type="xsd:unsignedShort" use="required"/>
<xsd:attribute name="ImageId" type="xsd:unsignedByte" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:key name="PK">
<xsd:selector xpath="Images/Image"/>
<xsd:field xpath="#ImageId"/>
</xsd:key>
<xsd:keyref name="FK" refer="PK">
<xsd:selector xpath="Banners/Banner"/>
<xsd:field xpath="#ImageId"/>
</xsd:keyref>
</xsd:element>
</xsd:schema>
Sample error message:
The key sequence '8' in Keyref fails to refer to some key.
xsd-restriction-by-value.xml is XSD 1.0 invalid.

JAXB - Overriding datatype of an element

I am using JAXB with the following customized binding :
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" version="2.0" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jaxb:globalBindings typesafeEnumMaxMembers="2000">
<jaxb:serializable />
</jaxb:globalBindings>
<jaxb:bindings schemaLocation="test.xsd" node="/xs:schema//xs:complexType[#name='EN']//xs:element[#name='family']">
<jaxb:property>
<jaxb:baseType name="java.lang.String" />
</jaxb:property>
</jaxb:bindings>
</jaxb:bindings>
to handle this schema (test.xsd):
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:complexType name="EN" mixed="true">
<xsd:complexContent>
<xsd:extension base="ANY">
<xsd:sequence>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="family" type="en.family"/>
</xsd:choice>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="en.family" mixed="true">
<xsd:complexContent>
<xsd:restriction base="ENXP">
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="ENXP" mixed="true">
<xsd:complexContent>
<xsd:extension base="ST">
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="ST" mixed="true">
<xsd:complexContent>
<xsd:restriction base="ED">
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="ED" mixed="true">
<xsd:complexContent>
<xsd:extension base="BIN">
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="BIN" abstract="true" mixed="true">
<xsd:complexContent>
<xsd:extension base="ANY">
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="ANY" abstract="true">
<xsd:attribute name="nullFlavor" type="xsd:string" use="optional">
</xsd:attribute>
</xsd:complexType>
</xsd:schema>
And I experiencing this problem :
[ERROR] compiler was unable to honor this property customization. It is attached to a wrong place, or its inconsistent with other bindings.
line 6 of file://home/user/test/jaxbelem_binding.xml
[ERROR] (the above customization is attached to the following location in the schema)
line 7 of file://home/user/test/test.xsd
Failed to parse a schema.
What's wrong with my binding file?
It's yaling about jaxb:property, but when the latter is deleted, no overriding happens!
Any help will be really appreciated, thanks in advance folks!
I have had luck nesting the jxb:bindings node tag inside of the jxb:bindings schemaLocation tag like this:
<?xml version="1.0" encoding="US-ASCII" ?>
<jxb:bindings version="2.0"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
>
<jxb:bindings schemaLocation="test.xsd">
<jxb:bindings node="//xs:element[#name='family']">
<jxb:property >
<jxb:baseType name="java.lang.String"></jxb:baseType>
</jxb:property>
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>
also:
while your note xpath to 'family' works, it seems overly complicated. I updated it to one that works given your example xsd (as long as there is only one element with name='family' it will work)

xml schema, precision of decimal value

This is my xml (not whole):
<xsd:complexType name="xx">
<xsd:complexContent>
<xsd:extension base="tns:xx">
<xsd:sequence>
<xsd:element name="rekVrednostDdv" nillable="true" type="decimal"/>
<xsd:element name="xx" nillable="true" type="dateTime"/>
<xsd:element name="xx" nillable="true" type="decimal"/>
<xsd:element name="xx" nillable="true" type="string"/>
<xsd:element name="xx" nillable="true" type="dateTime"/>
<xsd:element name="xx" nillable="true" type="string"/>
<xsd:element name="xx" nillable="true" type="decimal"/>
<xsd:element name="xx" nillable="true" type="decimal"/>
<xsd:element name="xx" nillable="true" type="string"/>
<xsd:element name="xx" nillable="true" type="string"/>
<xsd:element name="xx" nillable="true" type="decimal"/>
<xsd:element name="xx" nillable="true" type="tns:xx"/>
<xsd:element name="xx" nillable="true" type="dateTime"/>
<xsd:element name="xx" nillable="true" type="string"/>
<xsd:element name="xx" nillable="true" type="string"/>
<xsd:element name="xx" nillable="true" type="string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
For example rekVrednostDdv must have precision 2. How can i tell this type to have precision 2.
i try like this:
<xsd:element name="rekVrednostDdv" nillable="true">
<xsd:simpleType>
<xsd:restriction base="decimal">
<xsd:precision value="6"/>
<xsd:scale value="2"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
but now i get when using http://www.brainbell.com/tutorials/XML/Working_With_Simple_Types.htm
Invalid XML schema: 'Element <xsd:precision> is not allowed under element <xsd:restriction>.'
Create a new simple type that restricts xs:decimal and use <xs:fractionDigits/> to define the precision. Then refer to this type in your element definition.
<xs:simpleType name="decimalTwoPrec">
<xs:restriction base="xs:decimal">
<xs:fractionDigits value="2" />
</xs:restriction>
</xs:simpleType>
<xs:element name="rekVrednostDdv" nillable="true" type="decimalTwoPrec"/>
For more info, see the spec http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits

Resources