CURL command line with parameters - shell

Maybe thats a stupid question, but I am stopped because of this. I have the WSDL structure that is the following as the image:
<wsdl:types>
<xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:rfc:functions">
<xsd:simpleType name="char10">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char17">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="17"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char5">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="5"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char6">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="6"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:complexType name="AUTH">
<xsd:sequence>
<xsd:element name="TIPO" type="tns:char6"/>
<xsd:element name="USERNAME" type="tns:char10"/>
<xsd:element name="PASSWORD" type="tns:char10"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ASK">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="AUTHENTICATION" type="tns:AUTH"/>
<xsd:element name="REQUEST_NUMBER_IN" type="tns:char17"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="MY_RESP">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="PENDING" type="tns:string"/>
<xsd:element name="PHOTO" type="tns:string"/>
<xsd:element name="REQUEST_NUMBER_OUT" type="tns:char17"/>
<xsd:element name="STATUS" type="tns:char5"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
It is a must doing this first connection with curl in cmd (dont ask me why)
The command I am trying is:
curl "http://URL?username=user&password=pwd&tipo=0" --data #file.wsdl
But I get a message from the server that the login is wrong. What I want to ask is, am I filling the parameters correct?

There is a chance that your password may contain non-alphabetic characters and your shell is interpreting them accordingly to its special function instead of just reading your input as a simple, shell meaningless string. If that is the case, try to escape them and check if that is your issue.

Related

undefined complextype is used as a base for complex type extension

What is the problem in my WSDL file? The Visual Studio complains about an undefined complex type.
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns1="http://osmc.synium.com/services/presence" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns2="http://types.osqq.syqq.com" xmlns:impl="com.syqq.osqq.services.presence" xmlns:intf="com.syqq.osqq.services.presence" targetNamespace="com.syqq.osqq.services.presence" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://types.osqq.syqq.com">
<xsd:import namespace="http://osqq.syqq.com/services/presence" />
<xsd:import namespace="com.syqq.osqq.services.presence" />
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:complexType name="SoapBinaryMessage" abstract="true">
<xsd:sequence>
<xsd:element name="data64" nillable="true" type="xsd:string" />
<xsd:element name="version" nillable="true" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://osmc.synium.com/services/presence">
<xsd:import namespace="com.syqq.osqq.services.presence" />
<xsd:import namespace="http://types.osqq.syqq.com" />
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:complexType name="PresenceStatusBinary">
<xsd:complexContent mixed="false">
<xsd:extension base="tns2:SoapBinaryMessage">
<xsd:sequence />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
...
</wsdl:types>
Any ideas?
The problem occurs in line xsd:extension base="tns2:SoapBinaryMessage
You're missing the prefix declaration for tns2; this needs to be added somewhere such that it'll be in scope for the <xsd:extension base="tns2:SoapBinaryMessage"> node (the best place as far as I am concerned might be the second xsd:schema declaration):
xmlns:tns2="http://types.osqq.syqq.com"

xsd validation in CodeIgniter

I am using CodeIgniter, and I want to validate xml with below xsd
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:simpleType name="non_empty_string">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1" />
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="xml">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="item">
<xsd:simpleType>
<xsd:union memberTypes="non_empty_string xsd:integer"/>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
when I am trying to validate xml against this xsd, only first member type is getting validated (non_empty_string ), not the second one, any guess why this is happening. Thank you.
You can use XMLReader to validate your XML against xsd file.
refer this link for more information
http://de.php.net/manual/en/xmlreader.setschema.php

JAXB unmarshal validation throws cvc-elt.1: Cannot find the declaration of element error

I'm kind of new to JAXB and validation, and have spent several hours trying to figure out this problem to no avail. I've created a simple JAXB unmarshaller sample to parse an XML file. I have created an appropriate XSD file as well, but the validator keeps complaining that it is unable to find the declaration of an element.
I think it may be related to namespace issues, but I've tried everything I can think of and still can't seem to resolve the error. As far as I can tell, my XSD and XML are proper, so it may have to do with the way I am instantiating the unmarshaller, but I can't seem to find the problem anywhere.
The error/exception I keep getting is:
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'calculateBorrowingDataResponse'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
at org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startElement(ValidatingUnmarshaller.java:85)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:47)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:113)
at com.sun.xml.internal.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:236)
at com.sun.xml.internal.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:119)
at com.sun.xml.internal.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:102)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:299)
... 2 more
Here are the source files that are causing the error.
Java Code:
// We need a Document
InputStream is = UnmarshalTest.class.getClassLoader().getResourceAsStream("calculateBorrowingDataResponse.xml");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Node node = db.parse(is);
// Creating an unmarshaller
Unmarshaller u = JAXBContext.newInstance(CalculateBorrowingDataResponseType.class).createUnmarshaller();
// Setting the Validation
Schema schema;
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
schema = schemaFactory.newSchema(new File("src/main/webapp/WEB-INF/wsdl/CalculateBorrowingDataResponse.xsd"));
u.setSchema(schema);
u.unmarshal(node, CalculateBorrowingDataResponseType.class);
CalculateBorrowingDataResponse.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
version="1.1"
attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://www.domain.com/ClientServices/LendingSimulation/CalculateBorrowingDataResponse"
xmlns:lssSt="http://www.domain.com/ClientServices/LendingSimulation/CalculateBorrowingDataResponse"
xmlns:cbdRes="http://www.domain.com/ClientServices/LendingSimulation/CalculateBorrowingDataResponse"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- CalculateBorrowingData -->
<xsd:complexType name="CalculateBorrowingDataResponseType">
<xsd:sequence>
<xsd:element name="loanAgmt" type="cbdRes:LoanAgreementType" minOccurs="1" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="LoanAgreementType">
<xsd:sequence>
<xsd:element name="borrowingBasedPmtAmt" type="lssSt:borrowingBasedPmtAmt" minOccurs="0" maxOccurs="1" />
<xsd:element name="maxPmtAmt" type="lssSt:maxPmtAmt" minOccurs="0" maxOccurs="1" />
<xsd:element name="borrowingCapacityMin" type="lssSt:borrowingCapacityMin" minOccurs="0" maxOccurs="1" />
<xsd:element name="borrowingCapacityMax" type="lssSt:borrowingCapacityMax" minOccurs="0" maxOccurs="1" />
<xsd:element name="propertyValueMinAmt" type="lssSt:propertyValueMinAmt" minOccurs="0" maxOccurs="1" />
<xsd:element name="propertyValueMaxAmt" type="lssSt:propertyValueMaxAmt" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="calculateBorrowingDataResponse" type="cbdRes:CalculateBorrowingDataResponseType"/>
<xsd:simpleType name="borrowingBasedPmtAmt">
<xsd:restriction base="xsd:decimal" >
<xsd:totalDigits value="19" />
<xsd:fractionDigits value="4" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="maxPmtAmt">
<xsd:restriction base="xsd:decimal" >
<xsd:totalDigits value="19" />
<xsd:fractionDigits value="4" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="borrowingCapacityMin">
<xsd:restriction base="xsd:decimal" >
<xsd:totalDigits value="19" />
<xsd:fractionDigits value="4" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="borrowingCapacityMax">
<xsd:restriction base="xsd:decimal" >
<xsd:totalDigits value="19" />
<xsd:fractionDigits value="4" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="propertyValueMinAmt">
<xsd:restriction base="xsd:decimal" >
<xsd:totalDigits value="19" />
<xsd:fractionDigits value="4" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="propertyValueMaxAmt">
<xsd:restriction base="xsd:decimal" >
<xsd:totalDigits value="19" />
<xsd:fractionDigits value="4" />
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
calculateBorrowingDataResponse.xml
<?xml version="1.0" encoding="UTF-8"?>
<calculateBorrowingDataResponse
xmlns="http://www.domain.com/ClientServices/LendingSimulation/CalculateBorrowingDataResponse"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns2="http://www.domain.com/ClientServices/LendingSimulation/V1.1">
<loanAgmt>
<borrowingBasedPmtAmt>1231231</borrowingBasedPmtAmt>
<maxPmtAmt>987654321</maxPmtAmt>
<borrowingCapacityMax>99999</borrowingCapacityMax>
</loanAgmt>
</calculateBorrowingDataResponse>
I tried both with and without the last element definition in the XSD (ie: xsd:element name="calculateBorrowingDataResponse" ... ) but neither work.
I'm running out of ideas of different things to try. Any suggestions or recommendations would be greatly appreciated!
This is the fourth hour that I'm trying to find the source of the problem. After much struggle, now, I'm confident that you're missing a single line of code to be able to rise to glorious heights!
The problem is that DocumentBuilderFactory created via DocumentBuilderFactory.newInstance() by default isn't namespace aware—yeah.
You can overcome this in two ways:
make your DocumentBuilderFactory namespace aware:
DocumentBuilderFactory.setNamespaceAware(true);
or use a StreamSource while unmarshalling and drop the DocumentBuilder and his little friends altogether:
Unmarshaller.unmarshal(StreamSource, Class<T>);
In case of the second choice you're to do it like this.
InputStream xsdStream = ...
InputStream xmlStream = ...
SchemaFactory f = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema s = schemaFactory.newSchema(xsdStream);
JAXBContext c = JAXBContext.newInstance(CalculateBorrowingDataResponseType.class);
Unmarshaller u = c.createUnmarshaller();
u.setSchema(schema);
CalculateBorrowingDataResponseType b =
u.unmarshal(new StreamSource(xmlStream), CalculateBorrowingDataResponseType.class);
By the way, on this schema-awareness-ness-document-builderness-awesomeness there is a lot info in the top section of the Unmarshaller class' documentation, you should definitely check that out!

What is wrong with this xsd?

The following XSD should validate that the favorite_fruit element's name attribute should only contain names of fruit in the fruits element. Here is the XSD:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="Fruit">
<xsd:attribute name="name" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="FruitArray">
<xsd:sequence>
<xsd:element name="fruit" minOccurs="0" maxOccurs="unbounded" type="Fruit"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="fruit_basket">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="fruits" minOccurs="1" maxOccurs="1" type="FruitArray"/>
<xsd:element name="favourite_fruit" minOccurs="1" maxOccurs="1">
<xsd:complexType>
<xsd:attribute name="name" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:key name="fruit_lookup">
<xsd:selector xpath="fruits/fruit"/>
<xsd:field xpath="#name"/>
</xsd:key>
<xsd:keyref name="favourite_fruit_constraint" refer="fruit_lookup">
<xsd:selector xpath="favourite_fruit"/>
<xsd:field xpath="#name"/>
</xsd:keyref>
</xsd:element>
</xsd:schema>
The following xml should be valid but when validated is invalid:
<fruit_basket>
<fruits>
<fruit name="Apple"/>
<fruit name="Peach"/>
<fruit name="Bananna"/>
</fruits>
<favourite_fruit name="Apple"/>
</fruit_basket>
Any ideas? My gut feels is that there is something wrong with my xpath. PS: I am using lxml to validate the xml against the xsd.
The anonymous complex type specifies a attribute 'name' without a type. The Fruit type has a attribute 'name' with a type of : xsd:string. Because the two attributes doesn't have the same type they can't match. Thus changing the anonymous complex type attribute definition to : works.
You have not given a type to the xsd:element of favourite_fruit. So the schema cannot validate against the type Fruit:
<xsd:element name="favourite_fruit" minOccurs="1" maxOccurs="1">
<xsd:complexType>
<xsd:attribute name="name" use="required"/>
</xsd:complexType>
</xsd:element>
Nowhere are you constraining the type to be a Fruit. This should work better:
<xsd:element name="favourite_fruit" minOccurs="1" maxOccurs="1" Type="Fruit" />

Validating XML: No matching global declaration available for the validation root

I'm trying to validate the following XML against a XSD schema using Ruby.
It simply won't work, stops with an error message telling me
Error: Element 'request': No matching global declaration available for the validation root.
Maybe it's the namespace? Any ideas?
XML
<?xml version="1.0" encoding="UTF-8"?>
<request type="test" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<channel name="channel">
<username>user</username>
<password>pass</password>
</channel>
<hotel id="1">
<date from="2009-07-07" to="2009-07-17"/>
<room id="1">
<allocation>10</allocation>
</room>
</hotel>
</request>
XSD
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- channel -->
<xsd:element name="channel">
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:sequence>
<xsd:element username="name" use="required" type="xsd:string"/>
<xsd:element password="country" use="required" type="xsd:string"/>
</xsd:sequence>
</xsd:element>
<!-- hotel -->
<xsd:element name="hotel">
<xsd:attribute name="id" use="required" type="xsd:string" />
<xsd:sequence>
<xsd:element name="hotel">
<xsd:attribute name="from" use="required" type="xsd:string" />
<xsd:attribute name="to" use="required" type="xsd:string" />
</xsd:element>
<xsd:element ref="room" minOccurs="1"/>
</xsd:sequence>
</xsd:element>
<!-- room -->
<xsd:element name="room">
<xsd:sequence>
<xsd:element name="allocation" type="xsd:string"></xsd:element>
<xsd:element ref="hotel" minOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="id" use="required" type="xsd:string" />
</xsd:element>
<!-- building all together -->
<xsd:element name="request">
<xsd:attribute name="type" use="required" type="xsd:string" />
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="channel" maxOccurs="1"/>
<xsd:element ref="hotel" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Ruby code
require "xml"
document = LibXML::XML::Document.file("/tmp/test.xml")
schema = LibXML::XML::Document.file("/tmp/request.xsd")
result = document.validate_schema(schema) do |message,flag|
log.debug(message)
puts message
end
It's a cryptic error, but it's probably because your XSD is malformed. For example, the contents of the channel, hotel (both the inner and outer elements), room, and request xsd:element tags should all be wrapped in xsd:complexType tags. Also, use is only valid on xsd:attribute, not xsd:element. For elements, use minOccurs and maxOccurs (although both default to 1, so they aren't actually necessary in this case). In addition, your outer hotel element contains a room element, which must contain a hotel element, creating an infinite loop. Further, you don't name your username and password elements properly. Finally, that inner hotel element should probably be date. Here's what I think you're looking for:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- channel -->
<xsd:element name="channel">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="username" type="xsd:string"/>
<xsd:element name="password" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<!-- hotel -->
<xsd:element name="hotel">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="date">
<xsd:complexType>
<xsd:attribute name="from" use="required" type="xsd:string" />
<xsd:attribute name="to" use="required" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element ref="room" minOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="id" use="required" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<!-- room -->
<xsd:element name="room">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="allocation" type="xsd:string"></xsd:element>
</xsd:sequence>
<xsd:attribute name="id" use="required" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<!-- building all together -->
<xsd:element name="request">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="channel" maxOccurs="1"/>
<xsd:element ref="hotel" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="type" use="required" type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:schema>
Just shooting from the hip here, but have you tried converting the XML::Document holding the schema into an XML::Schema?
http://libxml.rubyforge.org/rdoc/classes/LibXML/XML/Schema.html
I don't know that it would make a difference, but it's worth a shot.
I received the same cryptic error message for a different reason.
The first line of my schema file had an unprefixed namespace:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sec.gov/edgar/document/thirteenf/informationtable" xmlns:ns1="http://www.sec.gov/edgar/common" targetNamespace="http://www.sec.gov/edgar/document/thirteenf/informationtable" elementFormDefault="qualified" attributeFormDefault="unqualified">
Note the 'xmlns=' attribute. This placed all the elements declared in the schema into the namespace http://www.sec.gov/edgar/document/thirteenf/informationtable (unless otherwise specified with a namespace prefix). But the XML file that I was trying to validate did not have a matching unprefixed/default namespace:
<informationTable xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
So its elements didn't match the schema because they were in "different" namespaces. I hope this is useful to others.

Resources