I'm new to spring boot and web services and am trying to create a soap webservice, I followed a tutorial but i keep getting the below error:
SAAJ0511: Unable to create envelope from given source
the code snippet is as below:
thats the xsd :
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.binarystorage.com/binary-storage-soap"
xmlns:tns="http://www.binarystorage.com/binary-storage-soap"
elementFormDefault="qualified">
<element name="store-request" type="tns:binaryData"/>
<element name="store-response" type="tns:idBody"/>
<element name="retrieve-request" type="tns:idBody"/>
<element name="retrieve-response" type="tns:binaryData"/>
<element name="remove-request" type="tns:idBody"/>
<element name="remove-response"/>
<complexType name="binaryData">
<sequence>
<element name="name" type="string"/>
<element name="content" type="string"/>
<element name="content-type" type="string"/>
<element name="meta" minOccurs="0" maxOccurs="unbounded">
<complexType>
<attribute name="key" type="string"></attribute>
<attribute name="value" type="string"></attribute>
</complexType>
</element>
</sequence>
</complexType>
<complexType name="idBody">
<sequence>
<element name="id" type="string"/>
</sequence>
</complexType>
</schema>
and the screen shot below is my try for an endpoint :
Please advice
Thanks
Related
When using the Axis2 WSDL2Java tool, the array seems to be not typed and therefore have to cast an object to add it.
<element name="FunnyObject" nillable="true">
<complexType>
<sequence>
<element name="id" type="string" />
<element name="joke" type="string" />
</sequence>
</complexType>
</element>
<element name="FunnyObjects" nillable="true">
<complexType>
<complexContent mixed="false">
<restriction base="SOAP-ENC:Array">
<attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="FunnyObject[]" />
</restriction>
</complexContent>
</complexType>
</element>
Any ideas what edits I need to do? New to WSDL as just learning it for a course (unfortunately in 2019).
We have custom java code that deployed in the JBoss. We are firing the webservice call and the WSDL file is generating by using the Apache Axis framework.
My question is for some of the tag, minOccurs and maxOccurs attribute is present, but for some other tag, those attributes are not present.
If I want minOccurs and maxOccurs attribute inside the element tag, then where I have to configure? How this Apache Axis framework will generate these attribute.
Sample WSDL :
<wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="urn:sif.siperian.com" xmlns:intf="urn:sif.siperian.com"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:sif.siperian.com">
<!--
WSDL created by Apache Axis version: 1.3
Built on Oct 05, 2005 (05:23:37 EDT)
-->
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" targetNamespace="urn:sif.siperian.com">
<complexType name="Account">
<sequence>
<element name="accountNumber" nillable="true" type="xsd:string"/>
<element name="accountType" nillable="true" type="xsd:string"/>
<element name="cardholderName" nillable="true" type="xsd:string"/>
<element name="city" nillable="true" type="xsd:string"/>
<element name="expirationMonth" nillable="true" type="xsd:string"/>
<element name="expirationYear" nillable="true" type="xsd:string"/>
<element name="hubStateInd" nillable="true" type="xsd:string"/>
<element name="issuingCompany" nillable="true" type="xsd:string"/>
<element name="pkeySrcObject" nillable="true" type="xsd:string"/>
<element name="postalCode" nillable="true" type="xsd:string"/>
<element name="rowidObject" nillable="true" type="xsd:string"/>
<element name="securityCode" nillable="true" type="xsd:string"/>
<element name="source" nillable="true" type="xsd:string"/>
<element name="stateProvince" nillable="true" type="xsd:string"/>
<element name="streetName" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
<complexType name="ArrayOfAccount">
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="item"
type="impl:Account"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
</wsdl:definitions>
In the above WSDL, the <complexType name="Account"> is not having property minOccurs and maxOccurs.
Where as, the <complexType name="ArrayOfAccount"> is having both the properties.
The following is a Java Code sample on how to build the following element:
<element maxOccurs="1" minOccurs="0" name="Test" nillable="true" type="xsd:string"/>
Java Code:
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("test");
elemField.setXmlName(new javax.xml.namespace.QName("http://www.test.com", "Test"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(true);
Hope this helps.
So, I have an object which can contain a list of Objects of that type. I wrote an XSD which looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="myNamespace" elementFormDefault="qualified">
<complexType name="BinModel">
<sequence>
<element type="string" name="min" />
<element type="string" name="max" />
<element type="string" name="fieldname" />
<element type="int" name="defaultValue" />
<element xmlns:ref="BinModel" name="innerBins" maxOccurs="unbounded" minOccurs="0" />
</sequence>
</complexType>
<element name="AllBins">
<complexType>
<sequence>
<element type="string" name="fieldnames" maxOccurs="unbounded" minOccurs="0"/>
<element type="int" name="defaultValue"/>
<element xmlns:type="BinModel" name="outerBins" maxOccurs="unbounded" minOccurs="0" />
</sequence>
</complexType>
</element>
</schema>
It produces two java classes, BinModel and AllBins respectively, but in each of those classes, even though I specify that they contain a list of type BinModel, it produces a List of type Object.
How do I generate a class which has a List of BinModels?
So I realized something was wrong when it took me adding xmlns before type and ref in order to not show errors in the editor. I looked at another xsd for a recursively defined Object somewhere else in my stupidly huge codebase to try and find a solution and discovered two things.
1. We were defining our own namespace
2. We referenced our own objects within that namespace.
So the corrected code looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:myProject="projectNamespace" targetNamespace="myNamespace" elementFormDefault="qualified">
<complexType name="BinModel">
<sequence>
<element type="string" name="min" />
<element type="string" name="max" />
<element type="string" name="fieldname" />
<element type="int" name="defaultValue" />
<element type="myProject:BinModel" name="innerBins" maxOccurs="unbounded" minOccurs="0" />
</sequence>
</complexType>
<element name="AllBins">
<complexType>
<sequence>
<element type="string" name="fieldnames" maxOccurs="unbounded" minOccurs="0"/>
<element type="int" name="defaultValue"/>
<element type="myProject:BinModel" name="outerBins" maxOccurs="unbounded" minOccurs="0" />
</sequence>
</complexType>
</element>
</schema>
I need to valid XSD for a XML file.
This is xml file.
<?xml version="1.0" encoding="UTF-8"?>
<edge xmlns="http://www.example.org/flow">
<flowPara
style="letter-spacing:0px;fill:#000000;
font-size:9pt;font-family:Arial;text-anchor:start;text-align:start;"
id="textArea_38">
Text Flow checking and
<flowSpan style="fill:#FA0101; ">
font color change
text
<flowSpan style="fill:#C5A2A2; " />
</flowSpan>
in
<flowSpan
style="font-style:italic;letter-spacing:0px;fill:#000000;
font-size:9pt;font-family:Arial;text-anchor:start;text-align:start;">text
area
</flowSpan>
.
<flowSpan style="letter-spacing:0px;">
<flowSpan
style="text-decoration:underline;letter-spacing:0px;fill:#000000;
font-size:9pt;font-family:Arial;text-anchor:start;text-align:start;">Text
Flow
</flowSpan>
checking and
<flowSpan style="fill:#FA0101; ">
font color
change text
<flowSpan style="fill:#C5A2A2; ">
<flowSpan style="fill:#000000;
">in text area.</flowSpan>
</flowSpan>
</flowSpan>
</flowSpan>
</flowPara>
</edge>
This is XSD file which i created .
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/flow"
xmlns:tns="http://www.example.org/flow" elementFormDefault="qualified">
<element name="edge">
<complexType>
<sequence>
<element name="flowPara" maxOccurs="unbounded">
<complexType mixed="true">
<sequence>
<element name="flowspan" maxOccurs="unbounded">
<complexType mixed="true">
<sequence>
<element name="flowspan" maxOccurs="unbounded">
<complexType mixed="true">
<simpleContent>
<extension base="string">
<attribute name="style" type="string" />
</extension>
</simpleContent>
</complexType>
</element>
</sequence>
<attribute name="style" type="string" />
</complexType>
</element>
</sequence>
<attribute name="style" type="string" />
<attribute name="id" type="string" />
</complexType>
</element>
</sequence>
</complexType>
</element>
</schema>
i faced this kind of exception
Exception: cvc-complex-type.2.4.b: The content of element 'flowPara' is not complete. One of '{"http://www.example.org/flow":flowspan}' is expected.
1) In your schema, you have flowspan with the s in lowercase in several places. Change that to flowSpan.
2) You declared mixed content, but your flowSpan element is not optional, so it will always be required and will not validate it if the contents of flowSpan don't contain another flowSpan. Add minOccurs="0" so it becomes optional.
3) You don't need to declare simple content if you have mixed content with an optional nested flowSpan. Your schema could be reorganized using a reference for flowSpan, since it's used recursively. You could try this:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/flow"
xmlns:tns="http://www.example.org/flow"
elementFormDefault="qualified">
<element name="edge">
<complexType>
<sequence>
<element name="flowPara" maxOccurs="unbounded">
<complexType mixed="true">
<sequence>
<element ref="tns:flowSpan" maxOccurs="unbounded"/>
</sequence>
<attribute name="style" type="string" />
<attribute name="id" type="string" />
</complexType>
</element>
</sequence>
</complexType>
</element>
<element name="flowSpan">
<complexType mixed="true">
<sequence>
<element ref="tns:flowSpan" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="style" type="string" />
</complexType>
</element>
</schema>
You didn't say minOccurs='0', so it requires one.
I am using JAXB and can't figure out why my nested objects aren't being unmarshalled. I am generating the classes via the XJC command.
For example, when I unmarshall the Works object, the Composers collection always contains one Composer instance will a NULL name.
My XML looks like this:
<Works>
<Work>
<Composer>
<Name>Test Name</Name>
</Composer>
</Work>
</Works>
and XSD is like this:
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
jxb:version="2.0" xmlns:tns="http://www.example.org/test/"
targetNamespace="http://www.example.org/test/">
<element name="Works" type="tns:Work"></element>
<complexType name="Work">
<sequence>
<element name="Composers" type="tns:Composer" maxOccurs="unbounded"
minOccurs="1">
</element>
</sequence>
</complexType>
<complexType name="Composer">
<sequence>
<element name="Name" type="string">
</element>
</sequence>
</complexType>
And my code that does the unmarshalling:
JAXBContext jc = JAXBContext.newInstance("mypackagename");
Unmarshaller um = jc.createUnmarshaller();
Works works = (Works)um.unmarshal(new FileReader("src/main/resources/works.xml"));
Work work = works.getWorks().get(0);
Composer composer = work.getComposers().get(0);
System.out.println(composer.getName());
Name is always NULL, even though I know it has a value.
You could have an XML schema like:
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
jxb:version="2.0" xmlns:tns="http://www.example.org/test/"
targetNamespace="http://www.example.org/test/">
<element name="Works" type="tns:Works"></element>
<complexType name="Works">
<sequence>
<element name="Work" type="tns:Work" maxOccurs="unbounded"/>
</sequence>
</complexType>
<complexType name="Work">
<sequence>
<element name="Composer" type="tns:Composer" maxOccurs="unbounded"/>
</sequence>
</complexType>
<complexType name="Composer">
<sequence>
<element name="Name" type="string"/>
</sequence>
</complexType>
</schema>
That corresponds to the following XML:
<Works xmlns="http://www.example.org/test/">
<Work>
<Composer>
<Name>Test Name</Name>
</Composer>
</Work>
</Works>