I have validation sequence that will validate incoming XML message using defined XSD. I have
used local registry to specify file location of the main XSD file (TP.xsd). TP.xsd definition is
importing another XSD (CORE.xsd) located on the same physical location. So when I try to test the
code, the first message failed to validate because data element definition was not found which is
located in CORE.xsd even the defintion exists. But on the succeeding incoming message, the message
get validated against the schema with no 'data element defintion not found' error. Can have someone
provide me how XSD has been loaded in ws02 esb? Is this being cached?
This is the error thrown in ws02 server logs:
2013-01-15 18:53:39,922 [-] [HttpServerWorker-6] ERROR ValidateMediator Error creating a new schema objects for schemas : [TPXSD-KEY]
org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'DateTimeType' to a(n) 'type definition' component.
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.xs.traversers.XSDHandler.reportSchemaError(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.getGlobalDecl(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDElementTraverser.traverseNamedElement(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDElementTraverser.traverseGlobal(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.traverseSchemas(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
at org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source)
Snippet of Core.xsd file:
<xsd:complexType name="DateTimeType">
<xs:sequence>
<xs:element ref="Year"/>
<xs:element ref="Month"/>
<xs:element ref="Day"/>
<xs:element ref="Hour" minOccurs="0"/>
<xs:element ref="Minute" minOccurs="0"/>
<xs:element ref="Second" minOccurs="0"/>
<xs:element ref="Fraction" minOccurs="0"/>
<xs:element ref="TimeZone" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
You have to edit your main XSD, point your import schema's location. That is, you have to correctly give the registry path of your second schema's to the first main schema. Then only, when message hits the sequence, it can resolve the schema.
Related
I'm trying to send an e-mail from within a C++ application via a Microsoft Exchange 2010 server. For this, I use the EWS protocol using the library ews-cpp.
The following trivial example, based on the one from https://github.com/otris/ews-cpp/blob/master/examples/send_message.cpp, is failing (mail addresses and credentials stripped from my actual code):
#include <iostream>
#include <ews/ews.hpp>
struct {
std::string domain = "mailserver";
std::string username = "...";
std::string password = "...";
std::string server_uri = "https://mailserver/EWS/Exchange.asmx";
} env;
int main()
{
ews::set_up();
try
{
auto service = ews::service(env.server_uri, env.domain, env.username,
env.password);
service.set_request_server_version(ews::server_version::exchange_2010_sp2);
auto message = ews::message();
message.set_subject("Test mail from outer space");
std::vector<ews::mailbox> recipients;
recipients.push_back(ews::mailbox("..."));
message.set_to_recipients(recipients);
auto text = ews::body("This is a test.");
message.set_body(text);
service.create_item(message,
ews::message_disposition::send_and_save_copy);
}
catch (ews::schema_validation_error& exc)
{
std::cout << exc.what() << std::endl;
std::cout << exc.violation() << std::endl;
}
ews::tear_down();
return 0;
}
The raw SOAP request is as follows (indentation added by me):
<m:CreateItem MessageDisposition="SendAndSaveCopy">
<m:Items>
<t:Message>
<t:Subject>Test mail from outer space</t:Subject>
<t:ToRecipients>
<t:Mailbox>
<t:EmailAddress>...</t:EmailAddress>
</t:Mailbox>
</t:ToRecipients>
<t:Body BodyType="Text">This is a test.</t:Body>
</t:Message>
</m:Items>
</m:CreateItem>
The function create_item throws an ews::schema_validation_error which is caught in the above code, printing:
The request failed schema validation
The element 'Message' in namespace ‘http://schemas.microsoft.com/exchange/services/2006/types’ has invalid child element 'Body' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'. List of possible elements expected: 'CcRecipients, BccRecipients, IsReadReceiptRequested, IsDeliveryReceiptRequested, ConversationIndex, ConversationTopic, From, InternetMessageId, IsRead, IsResponseRequested, References, ReplyTo, ReceivedBy, ReceivedRepresenting' in Namespace 'http://schemas.microsoft.com/exchange/services/2006/types'.
In other words, EWS doesn't expect <t:Body> within <t:Message>.
So, when leaving out that element in the SOAP request (comment out message.set_body(text)), the mail is sent smoothly. However, a mail without a body doesn't make much sense, does it?
I thought that the problem might be the fact that ews-cpp was written for Exchange 2013 (and that the schema changed between 2010 and 2013 in this regard). So I digged into the schema, which each Exchange server serves at /ews/types.xsd, to see if the schema allows such a child element.
In the schema definition file, I found the definition of the type MessageType (which is the type of the Message element we are talking about):
<xs:complexType name="MessageType">
<xs:complexContent>
<xs:extension base="t:ItemType">
<xs:sequence>
<xs:element name="Sender" minOccurs="0" type="t:SingleRecipientType"/>
<xs:element name="ToRecipients" type="t:ArrayOfRecipientsType" minOccurs="0"/>
<xs:element name="CcRecipients" type="t:ArrayOfRecipientsType" minOccurs="0"/>
<xs:element name="BccRecipients" type="t:ArrayOfRecipientsType" minOccurs="0"/>
<xs:element name="IsReadReceiptRequested" type="xs:boolean" minOccurs="0"/>
<xs:element name="IsDeliveryReceiptRequested" type="xs:boolean" minOccurs="0"/>
<xs:element name="ConversationIndex" type="xs:base64Binary" minOccurs="0"/>
<xs:element name="ConversationTopic" type="xs:string" minOccurs="0"/>
<xs:element name="From" type="t:SingleRecipientType" minOccurs="0"/>
<xs:element name="InternetMessageId" type="xs:string" minOccurs="0"/>
<xs:element name="IsRead" type="xs:boolean" minOccurs="0"/>
<xs:element name="IsResponseRequested" type="xs:boolean" minOccurs="0"/>
<xs:element name="References" type="xs:string" minOccurs="0"/>
<xs:element name="ReplyTo" type="t:ArrayOfRecipientsType" minOccurs="0"/>
<xs:element name="ReceivedBy" type="t:SingleRecipientType" minOccurs="0"/>
<xs:element name="ReceivedRepresenting" type="t:SingleRecipientType" minOccurs="0"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
As you can see, there is no Body child element, but MessageType is based on ItemType, which is defined as follows (excerpt):
<xs:complexType name="ItemType">
<xs:sequence>
<xs:element name="MimeContent" type="t:MimeContentType" minOccurs="0"/>
<xs:element name="ItemId" type="t:ItemIdType" minOccurs="0"/>
<xs:element name="ParentFolderId" type="t:FolderIdType" minOccurs="0"/>
<xs:element name="ItemClass" type="t:ItemClassType" minOccurs="0"/>
<xs:element name="Subject" type="xs:string" minOccurs="0"/>
<xs:element name="Sensitivity" type="t:SensitivityChoicesType" minOccurs="0"/>
<xs:element name="Body" type="t:BodyType" minOccurs="0"/>
<xs:element name="Attachments" type="t:NonEmptyArrayOfAttachmentsType" minOccurs="0"/>
[...]
</xs:sequence>
</xs:complexType>
As you can see, it accepts the Body element as a child.
Note that the Subject element is also defined in the ItemType and not in MessageType, and that is accepted by EWS in the above code snippet.
What might be the cause of this strange validation failure?
Found the solution myself:
For the element Message, which is based on Item according to the schema definition, EWS first expects all child elements for Item, followed by the Message-specific child elements.
This sounds very insane (to me), but swapping <t:ToRecipients> and <t:Body> in the <t:Message> element indeed solved the problem.
I did this by swapping the two corresponding setters in my code:
auto message = ews::message();
// First, set properties of the general "item":
message.set_subject("Test mail from outer space");
auto text = ews::body("This is a test.");
message.set_body(text);
// Then, set properties of the concrete "message":
std::vector<ews::mailbox> recipients;
recipients.push_back(ews::mailbox("..."));
message.set_to_recipients(recipients);
I'm not sure if this is a bug in ews-cpp, in EWS / Exchange server, or in the EWS schema definition.
I've generated an XSD from a set of example request files for an XML web service (using Xmplify - but I doubt that's important).
When I run this through gsoap, I get no errors or warnings, but even with -i or -j option on soapcpp2, I get no C++ proxy files generated (eg soapProxy.h).
Only the following files are generated:
ns1.nsmap
request.h
soapC.cpp
soapH.h
soapStub.h
Commands used:
wsdl2h request.xsd
soapcpp2 -i -C -I/usr/local/share/gsoap/import request.h
I figure there is something specific about the XSD required in order to generate these?
How do I get the proxy files generated? I know I can use without proxy objects, but it looks a lot more messy!
Schema doc is included below.
Thanks for any advice!
Phil.
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' elementFormDefault='unqualified'>
<xs:element name='REQUEST'>
<xs:complexType>
<xs:sequence>
<xs:element ref='USERTOKEN'/>
<xs:element ref='ACTION'/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name='USERTOKEN'>
<xs:complexType>
<xs:sequence>
<xs:element ref='USERKEY'/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name='USERKEY' type='xs:NCName'/>
<xs:element name='ACTION'>
<xs:complexType>
<xs:sequence>
<xs:element minOccurs='0' ref='PARAMETER'/>
</xs:sequence>
<xs:attribute name='NAME' use='required' type='xs:NCName'/>
</xs:complexType>
</xs:element>
<xs:element name='PARAMETER'>
<xs:complexType mixed='true'>
<xs:attribute name='NAME' use='required' type='xs:NCName'/>
</xs:complexType>
</xs:element>
</xs:schema>
The wsdl2h tool does not generate proxy and service code for XSD files, since there are no operations defined in these (only in WSDL). You can use the gSOAP-generated (de)serializers for the XSD root elements to send/recv XML data that is (de)serialized from the C++ data types. For example
#include "ns1.nsmap" // ns1 namespaces etc
struct soap *ctx = soap_new();
ns1__REQUEST r;
r.soap_default(ctx); // reset content
r.USERTOKEN = … // set r's content as needed
ctx.os = … // set the output stream
soap_write_ns1__REQUEST(ctx, &r); // serialize REQUEST
You can send/recv data over streams, sockets, etc.
I am calling Webservice from adobe process .
my wsdl contains web method "storeDocument" which takes Document as input.
<xs:element name="storeDocument">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:java="java:org.w3c.dom" name="req" type="java:Document"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="storeDocumentResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
but when i generate request in webservice setting. it shows
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:res="http://resourceusage.resource.domain.services.nyss.ktv.tdc.com" xmlns:java="java:org.w3c.dom">
<soapenv:Header/>
<soapenv:Body>
<res:storeDocument>
<res:req>
<java:XmlStandalone>?</java:XmlStandalone>
<java:XmlVersion>?</java:XmlVersion>
<java:StrictErrorChecking>?</java:StrictErrorChecking>
<java:DocumentURI>?</java:DocumentURI>
</res:req>
</res:storeDocument>
</soapenv:Body>
</soapenv:Envelope>
I dont have idea how to invoke this service , i tried to give
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:res="http://resourceusage.resource.domain.services.nyss.ktv.tdc.com" xmlns:java="java:org.w3c.dom">
<soapenv:Header/>
<soapenv:Body>
<res:storeDocument>
<res:req>
<java:StrictErrorChecking>false</java:StrictErrorChecking>
<java:DocumentURI>{$ /process_data/#outputForm $}</java:DocumentURI>
</res:req>
</res:storeDocument>
</soapenv:Body>
</soapenv:Envelope>
But it is not working
it gives me error
<bea_fault:stacktrace xmlns:bea_fault="http://www.bea.com/servers/wls70/webservice/fault/1.0.0">com.bea.xml.XmlRuntimeException: java.lang.InstantiationException: org.w3c.dom.Document
at com.bea.staxb.runtime.internal.ClassLoadingUtils.newInstance(ClassLoadingUtils.java:137)
at com.bea.staxb.runtime.internal.ByNameRuntimeBindingType.createIntermediary(ByNameRuntimeBindingType.java:207)
at com.bea.staxb.runtime.internal.AttributeUnmarshaller.unmarshal(AttributeUnmarshaller.java:36)
at com.bea.staxb.runtime.internal.UnmarshalResult.unmarshalBindingType(UnmarshalResult.java:174)
at com.bea.staxb.runtime.internal.UnmarshalResult.unmarshalType(UnmarshalResult.java:212)
at com.bea.staxb.runtime.internal.UnmarshallerImpl.unmarshalType(UnmarshallerImpl.java:127)
at weblogic.wsee.bind.runtime.internal.LiteralDeserializerContext.unmarshalType(LiteralDeserializerContext.java:70)
at weblogic.wsee.bind.runtime.internal.BaseDeserializerContext.internalDeserializeType(BaseDeserializerContext.java:170)
at weblogic.wsee.bind.runtime.internal.BaseDeserializerContext.deserializeType(BaseDeserializerContext.java:87)
at weblogic.wsee.bind.runtime.internal.BaseDeserializerContext.deserializeWrappedElement(BaseDeserializerContext.java:133)
at weblogic.wsee.codec.soap11.SoapDecoder.decodePart(SoapDecoder.java:407)
at weblogic.wsee.codec.soap11.SoapDecoder.decodeParams(SoapDecoder.java:245)
at weblogic.wsee.codec.soap11.SoapDecoder.decodeParts(SoapDecoder.java:164)
at weblogic.wsee.codec.soap11.SoapDecoder.decode(SoapDecoder.java:117)
at weblogic.wsee.codec.soap11.SoapCodec.decode(SoapCodec.java:139)
at weblogic.wsee.ws.dispatch.server.CodecHandler.decode(CodecHandler.java:138)
at weblogic.wsee.ws.dispatch.server.CodecHandler.handleRequest(CodecHandler.java:39)
at weblogic.wsee.handler.HandlerIterator.handleRequest(HandlerIterator.java:127)
at weblogic.wsee.ws.dispatch.server.ServerDispatcher.dispatch(ServerDispatcher.java:85)
at weblogic.wsee.ws.WsSkel.invoke(WsSkel.java:80)
at weblogic.wsee.server.servlet.SoapProcessor.handlePost(SoapProcessor.java:66)
at weblogic.wsee.server.servlet.SoapProcessor.process(SoapProcessor.java:44)
at weblogic.wsee.server.servlet.BaseWSServlet$AuthorizedInvoke.run(BaseWSServlet.java:173)
at weblogic.wsee.server.servlet.BaseWSServlet.service(BaseWSServlet.java:92)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3231)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2002)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1908)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1362)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
Caused by: java.lang.InstantiationException: org.w3c.dom.Document
at java.lang.Class.newInstance0(Class.java:335)
at java.lang.Class.newInstance(Class.java:303)
at com.bea.staxb.runtime.internal.ClassLoadingUtils.newInstance(ClassLoadingUtils.java:135)
... 36 more
Caused by: java.lang.InstantiationException: org.w3c.dom.Document
at java.lang.Class.newInstance0(Class.java:335)
at java.lang.Class.newInstance(Class.java:303)
at com.bea.staxb.runtime.internal.ClassLoadingUtils.newInstance(ClassLoadingUtils.java:135)
at com.bea.staxb.runtime.internal.ByNameRuntimeBindingType.createIntermediary(ByNameRuntimeBindingType.java:207)
at com.bea.staxb.runtime.internal.AttributeUnmarshaller.unmarshal(AttributeUnmarshaller.java:36)
at com.bea.staxb.runtime.internal.UnmarshalResult.unmarshalBindingType(UnmarshalResult.java:174)
Please help..
With the LiveCycle Workbench you can use the WebServices Service to invoke other webservices.
On this website lctips.wordpress.com
you can find some examples.
You can also call webservice from the form with javascript or dataconnection.
invoking-a-web-service programmatically
I have problem in copying the output of a service response to the response message in BPEL .
The amount element has an attribute currency, How do I acheiev this ? All other copying seems to work fine, except copying an element to an attribute of another element.
The copy expression is below.
<copy>
<from variable="InvokePersistence_insert_OutputVariable"
part="ProBookingInitiationCollection" query="/ns3:ProBookingInitiationCollection/ns3:ProBookingInitiation/ns3:bookingDetail/ns3:isoCurrencyCd"/>
<to variable="outputVariable" part="payload"
query="/ns4:BookingConfirmation/ns4:amount/#ns4:currency"/>
</copy>
The excerpts from xsd is below
<xs:element name="amount">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:decimal">
<xs:attribute name="currency" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
Make sure that "outputVariable" output variable is properly initialised according to the schema and contains an attribute called "currency"
We have JAX-RPC style web service, with a complex type defined as follows:
<xs:complexType name = "SomeFault">
<xs:sequence>
<xs:element name = "errorMessages" type="some:ErrorMessageWSType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:simpleType name = "ErrorMessageWSType">
<xs:restriction base = "xs:NMTOKEN">
<xs:enumeration value = "INVALID_1"/>
<xs:enumeration value = "INVALID_2"/>
<xs:enumeration value = "INVALID_3"/>
</xs:restriction>
</xs:simpleType>
We are running into Marshaling exception on the server side when the response/fault complex type has a single array type field.
weblogic.wsee.codec.CodecException: Failed to encode
com.bea.xml.XmlException: failed to find a suitable binding type for
use in marshalling object
"[Lnamespace.type.ErrorMessageWSType;#693767e9". using schema type:
t=SomeFault#http://namespace/SOME/v1 java
type:namespace.type.ErrorMessageWSType[]
If we change SomeFault, by adding another element to the complex type the error goes away.
<xs:complexType name = "SomeFault">
<xs:sequence>
<xs:element name = "errorMessages" type="some:ErrorMessageWSType" maxOccurs="unbounded" />
<xs:element name = "dummyString" type="xsd:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
Are we doing something wrong during the wsdlc code generation or is this a known issue?
A similar question is already posted at https://forums.oracle.com/forums/thread.jspa?messageID=4462906, but without any response, any pointers would be great.
Thanks.
Don't know if this solves the "why" part of the question, but you could try rewriting the sequence part like:
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="errorMessages" type="some:ErrorMessageWSType"/>
</xs:sequence>
OTOH, what might be the mechanism that lets the second case work, but not the first?
Might it be that the marshaller then has to figure out what xsd:string means before checking what some:ErrorMessageWSType means, and then has to wake up a resolver or something?
This line of thought leads to the second approach I would try, which would be to declare ErrorMessageWSType before SomeFault (and perhaps in another namespace, just to see if that fixes anything).
Just my (tired) two cents, and I guess that both of these approaches presume a bug of some sort in the marshaller, because I can't really see that anything in your example code isn't according to the XML schema definition.