I have to generate separate wsdl for separate client.
entry.xsd -> entry.wsdl
migration.xsd -> migration.wsdl
I am using spring boot contract frist approach for generating wsdl from xsd definition. Problem is type are same for both xsd fiels like: credential, so I want to create a common xsd file and include/import in both xsd so can reduce redundant code.
like common.xsd -> entry.xsd, migration.xsd
but getting exception or soap client giving invalid error message.
Any help, how to generate wsdl from two xsd where one is base xsd file?
It's giving, failed to update interface. InvalidFormatException from SOAP Client.
entry.sxd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.test.com/idms-ws"
targetNamespace="http://www.test.com/idms-ws"
elementFormDefault="qualified">
<xs:include schemaLocation="common-element.xsd"></xs:include>
<xs:element name="updateMigrationStatusRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="credential" type="tns:credential" minOccurs="0"/>
<xs:element name="referenceNo" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
common-element.xsd
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="credential">
<xs:sequence>
<xs:element name="loginName" type="xs:string" minOccurs="0"/>
<xs:element name="password" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Related
Requirement is read data from file and invoke webservice. Target webservice can handle one payload at a time but there will be multiple payload in source.
So am using while loop to process payload one by one.
Issue: In target service EarningTypeInclusion is optional element, so in source some payload this element will be present and in some payload this option element will not be present.
<thresholdRequestInterface xmlns:xs="http://www.sample.com/ns/LMSReferrals">
<thresholdRequest>
<Referral>11</Referral>
<thresholdValue>100</thresholdValue>
<EarningTypeInclusion>
<earningType>positive</earningType>
<ProvisionId>1000</ProvisionId>
</EarningTypeInclusion>
</thresholdRequest>
<thresholdRequest>
<Referral>11</Referral>
<thresholdValue>100</thresholdValue>
</thresholdRequest>
</thresholdRequestInterface>
If am using assign activity, then selection failure fault will come when optional elements are not present in source payload. We are using BPEL 10g, no option in assign activity to supress selection failure fault.
So decided to use transformation inside while loop .
logic used
Read from file
assign Loop counter=1
Count of payload(read from file)
While loop counter<= Count of payload
pass loop counter param value to transform
transform source i.e thresholdRequest[loopcounter] to target
Invoke target web service
increment loop counter
end loop;
Problem is same data is getting trsnformed.
In the below example, referral 11 data is loading 3 times. I have checked conter value, its getting incremented but inside transformation same values are getting transformed.
<thresholdRequestInterface xmlns:xs="http://www.sample.com/ns/LMSReferrals">
<thresholdRequest>
<Referral>11</Referral>
<thresholdValue>100</thresholdValue>
<EarningTypeInclusion>
<earningType>positive</earningType>
<ProvisionId>1000</ProvisionId>
</EarningTypeInclusion>
</thresholdRequest>
<thresholdRequest>
<Referral>12</Referral>
<thresholdValue>100</thresholdValue>
</thresholdRequest>
<thresholdRequest>
<Referral>13</Referral>
<thresholdValue>100</thresholdValue>
<EarningTypeInclusion>
<earningType>positive</earningType>
<ProvisionId>1000</ProvisionId>
</EarningTypeInclusion>
</thresholdRequest>
</thresholdRequestInterface>
Source
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns="http://www.sample.com/ns/LMSReferrals" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.sample.com/ns/LMSReferrals" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="thresholdRequestInterface">
<xs:complexType>
<xs:sequence>
<xs:element name="thresholdRequest" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Referral" type="xs:string"/>
<xs:element name="thresholdValue" type="xs:int"/>
<xs:element name="EarningTypeInclusion" minOccurs="0" maxOccurs="1" >
<xs:complexType>
<xs:sequence>
<xs:element name="earningType" type="xs:stirng" />
<xs:element name="ProvisionId">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="20" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Please find the schema structure for source and target
Target
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns="http://www.sample.com/ns/LMSReferrals" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.sample.com/ns/LMSReferrals" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="thresholdRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="Referral" type="xs:string"/>
<xs:element name="thresholdValue" type="xs:int"/>
<xs:element name="EarningTypeInclusion" minOccurs="0" maxOccurs="1" >
<xs:complexType>
<xs:sequence>
<xs:element name="earningType" type="xs:stirng" />
<xs:element name="ProvisionId">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="20" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Please note schema validation is enabled at target webservice.
Is there a specific reason that you are using Transform.Try using ora:getElement('/thresholdRequestInterface /thresholdRequest',bpws:getVariable(loopCounter))
I have following example xml message:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<to>...</to>
<from>...</from>
<id>..</id>
<relatesTo>...</relatesTo>
<action>...</action>
<version>...</version>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<customComplexElement>
<a>a_v</a>
<b>b_v</b>
<c>c_v</c>
<d>d_v</d>
<e>e_v</e>
<f>f_v</f>
</customComplexElement>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
From which I have generated a xsd file with use of one of online tools:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified">
<import namespace="http://schemas.xmlsoap.org/soap/envelope/" schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"></import>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="id" type="xs:string"/>
<xs:element name="relatesTo" type="xs:string"/>
<xs:element name="action" type="xs:string"/>
<xs:element name="version" type="xs:string"/>
<xs:element name="customComplexElement">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="a"/>
<xs:element type="xs:string" name="b"/>
<xs:element type="xs:string" name="c"/>
<xs:element type="xs:string" name="d"/>
<xs:element type="xs:string" name="e"/>
<xs:element type="xs:string" name="f"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Then I generate the appropriate header file with wsdl2h.exe and then compile it with soapcpp2.exe compiler.
Then I try to read xml file with a function soap_read_customComplexElement() and all I get is SOAP_TAG_MISMATCH. This method seems to work if I get rid of all the soap stuff the message but I wonder if there are some functions in gSOAP to parse soap envelope, header and body?
I've had same problem. But i've just fixed it.
So, in my case i use this line of code.
struct soap *soap = soap_new1(SOAP_C_UTFSTRING | SOAP_XML_IGNORENS | SOAP_XML_TREE);
The key paramter is SOAP_XML_IGNORENS. This parameter ignore namespaces.
SOAP_XML_IGNORENS in: ignores the use of XML namespaces in input
The root of this problem is that you don't declare namespaces in your body content. That why gSoap don't know how to convert this xml.
This wouldn't be converted, because gSoap don't know what is ns4:
<ns4:ParseKeywords><ns4:Keyword>Hello</ns4:Keyword></ns4:ParseKeywords>
But if i declare namespace it will be converted
<ns4:ParseKeywords xmlns:ns4="com.idurdyev.idcommerce:ParseKeywords:1.0"><ns4:Keyword>Hello</ns4:Keyword></ns4:ParseKeywords>
I need a sample XSD to support multiple email recipients in a new element. I require each recipient email address in a different element. Can anyone help me with explanation?
Example:
<EmailReceipts>
<address1></address1>
<address2></address2>
</EmailReceipts>
First off, I'd recommend not embedding an index number in the address elements:
<EmailReceipts>
<address>john#example.com</address>
<address>mary#example.org</address>
</EmailReceipts>
Then this XSD will validate the above XML (as well as other XML documents with additional address elements):
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="EmailReceipts">
<xs:complexType>
<xs:sequence>
<xs:element name="address" maxOccurs="unbounded" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The above XSD will allow any string contents for the address elements. If you've like to be more strict, you could use a regular expression to limit the values for address:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="EmailReceipts">
<xs:complexType>
<xs:sequence>
<xs:element name="address" maxOccurs="unbounded" type="EmailAddressType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="EmailAddressType">
<xs:restriction base="xs:string">
<xs:pattern value="([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*#([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
Note that the above regular expression is one of many possible, each having various degrees of generality and specificity over a syntax that is more involved than you might imagine.
I do not know how to write xsd for this request down.
Method POST
Request Parameters
all required
Tag Name
publicId type String
publicIdType type String
actorType type String
startDate type Date
endDate type Date
example
<actor>
<actorPublicId>2424252</actorPublicId>
<actorPublicIdType>1341416</actorPublicIdType>
<actorType>test</actorType>
<startDate>2014-03-10T22:34:34.999+2:00</startDate>
<endDate>2014-03-10T22:34:34.999+2:00</endDate>
</actor>
Your XSD is ..
<xs:schema
attributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="yourNamespace"
xmlns:pref="yourNamespace">
<xs:element name="actor" type="pref:actor"/>
<xs:complexType name="actor">
<xs:sequence>
<xs:element type="xs:string" name="actorPublicId"/>
<xs:element type="xs:string" name="actorPublicIdType"/>
<xs:element type="xs:string" name="actorType"/>
<xs:element type="xs:dateTime" name="startDate"/>
<xs:element type="xs:dateTime" name="endDate"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
I'm working on a project that involves a simple web service, and have had a slew of little problems. It's an Apache CXF webservice (using JAX-WS, over SOAP). The service itself is pretty simple: receive a request, insert the request into a database, and return whether the insert was successful. I'd like to rely on XML validation to enforce a number of constraints on the request.
Full XML validation is very important to this project. So far, I've been unable to properly validate, though my service otherwise functions.
I'm pretty sure it all boils down to this error, which is preventing validation.
Feb 8, 2010 4:47:14 PM org.apache.cxf.wsdl.EndpointReferenceUtils createSchema
WARNING: SAXException for newSchema() on
org.xml.sax.SAXParseException: XML document structures must start and end within the same entity.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1414)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.endEntity(XMLDocumentFragmentScannerImpl.java:905)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.endEntity(XMLDocumentScannerImpl.java:605)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.endEntity(XMLEntityManager.java:1393)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1763)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipSpaces(XMLEntityScanner.java:1492)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanAttribute(XMLNSDocumentScannerImpl.java:442)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:277)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2755)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig.parse(SchemaParsingConfig.java:435)
at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig.parse(SchemaParsingConfig.java:491)
at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOMParser.parse(SchemaDOMParser.java:510)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:1802)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.resolveSchema(XSDHandler.java:1757)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.constructTrees(XSDHandler.java:909)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:569)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:552)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:519)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:485)
at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:210)
at org.apache.cxf.wsdl.EndpointReferenceUtils.createSchema(EndpointReferenceUtils.java:666)
at org.apache.cxf.wsdl.EndpointReferenceUtils.getSchema(EndpointReferenceUtils.java:690)
at org.apache.cxf.interceptor.AbstractInDatabindingInterceptor.setSchemaInMessage(AbstractInDatabindingInterceptor.java:109)
at org.apache.cxf.interceptor.AbstractInDatabindingInterceptor.getDataReader(AbstractInDatabindingInterceptor.java:94)
at org.apache.cxf.interceptor.AbstractInDatabindingInterceptor.getDataReader(AbstractInDatabindingInterceptor.java:99)
at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:66)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:109)
at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:98)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:406)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:178)
at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:142)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Feb 8, 2010 4:47:14 PM org.apache.cxf.wsdl.EndpointReferenceUtils createSchema
WARNING: Schema for: http://myproject.com/ws/schema
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:ns1="http://myproject.com/Schema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://myproject.com/ws/schema" version="1.0">
<xs:import namespace="http://myproject.com/Schema.xsd"/>
<xs:element name="InvalidDataFault" type="xs:string"/>
<xs:element name="RequestHeader">
<xs:complexType>
<xs:sequence>
<xs:element name="UserID" type="xs:string"/>
<xs:element name="Password" type="xs:string"/>
<xs:element name="CourtID" type="xs:positiveInteger"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="SecurityFault">
<xs:complexType>
<xs:sequence>
<xs:element name="user" type="xs:string"/>
<xs:element name="court" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="uploadData">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns1:DataPackage"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="uploadDataResponse" type="xs:anyType"/>
</xs:schema>
Anyone have any ideas?
Any chance you can try with the latest CXF snapshots? There was a bug in this area that was fixed last week related to creating schemas for validation from relatively large schemas. The fix for that may solve this as well.