Validating input XML structure
Hi All,
If i need to validate the input XML structure, is there any standard modules available. I heard some options are available in PI7.0..Can any one explain in detail for validating the structure without any custom programming.
Regards,
Babu
Hello Babu,
This feature will be avauilable in Stanndard from Pi 7.1 Currently you would need to have custom coding to do this.
/people/morten.wittrock/blog/2006/03/21/validating-messages-in-xi-using-xml-schema
/people/jacob.vandborg/blog/2005/11/29/schema-validation-of-incoming-message
http://help.sap.com/saphelp_nw70/helpdata/en/c4/e1343e8c7f6329e10000000a114084/frameset.htm
With Regards,
BVS
Similar Messages
-
Mapping complete input XML structure into one field on target
Hi,
I have a scenario where I need to map the complete input XML structure as it is, into one field on target side. so can we achieve this in Graphical Mapping? If yes, please share your valuable info.
Regards,
Shiva.Hello,
this is the java map code.just compile it and made a .zip file import it and use it Interface Mapping.
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.AbstractTrace;
import com.sap.aii.mapping.api.StreamTransformationConstants;
import java.util.Map;
import java.io.*;
public class PayloadToXMLField1 implements StreamTransformation {
String strXML = new String();
//Declare the XML tag for your XML message
String StartXMLTag = "<DocumentBody>";
String EndXMLTag = "</DocumentBody>";
//String StartXMLTag1 = "<Code>";
//String EndXMLTag1 = "</Code>";
AbstractTrace trace;
private Map param = null;
public void setParameter(Map param) {
this.param = param;
public void execute(InputStream in, OutputStream out) {
trace =
(AbstractTrace) param.get(
StreamTransformationConstants.MAPPING_TRACE);
trace.addInfo("Process Started");
try {
StringBuffer strbuffer = new StringBuffer();
byte[] b = new byte[4096];
for (int n;(n = in.read(b)) != -1;) {
strbuffer.append(new String(b, 0, n));
strXML = strbuffer.toString();
} catch (Exception e) {
System.out.println("Exception Occurred");
String outputPayload =
StartXMLTag
+ "<![CDATA["
+ strXML
+ "]]>"
+ EndXMLTag;
try {
out.write(outputPayload.getBytes());
trace.addInfo("Process Completed");;
} catch (Exception e) {
trace.addInfo("Process Terminated: Error in writing out payload");; -
XML structure validation by javascript
Hi All,
I’m trying to find solution for XML structure validation on opening the indesign document.
Is this possible by javascript.
by
hasviOr you could go directly to the source.
http://help.sap.com/saphelp_nw70/helpdata/en/c4/e1343e8c7f6329e10000000a114084/frameset.htm
Regards,
Henrique. -
Anamitra,
I didn't get a chance to work on this issue.
From my understanding I have quickly created a test wsdl and test xsd.
I don't know whether it will work. I have not tested it. It needs many
corrections.
Take a look at the attached wsdl and xsd and let me know your suggestion.
Scenario:
1. Exposed method:
public String requestPurchaseOrder(String poXML)
2. poXML should be of type po.xsd
3. Validation - ?? No Idea. For now manual validation.
I guess we both have similar requirement, if you get it working before me,
please post your finding.
Thanks,
Karthik.
"Anamitra" <[email protected]> wrote in message
news:[email protected]...
>
Hi karthik
I still dont get how the poXML can be represented by a schema in a WSDL.Can you
give me a sample wsdl for that?
Thanks
Anamitra
"Karthik V" <[email protected]> wrote:
Manoj:
Sorry, I got confused when you said, "the runtime will strip the xml
tags".
After your explanation, I understand that the runtime is actually going
to
perform some conversion without any loss of data.
To conclude, logically,
public void test(String poXML) is valid, and poXML can be represented
by
a schema definition.
When I get a chance, I'm going to create a quick example of this use
case
and post it.
Thanks,
/k
"manoj cheenath" <[email protected]> wrote in message
news:[email protected]...
java.lang.String is mapped to xsd:string which means the xml
should look like:
<foo xsi:type=xsd:string >sometext without any xml tags</foo>
So if there are xml tags inside the string you passed
in, runtime need to replace the tags with > and
<.
On the other end the runtime will again replace
etc back to < or >. So you will get back theright XML. But on the wire it will be plain text
not XML.
So, if you dont want to convert to string, then you should use
javax.xml.soap.SOAPElement or org.w3c.Element as
your parameter type instead of java.lang.String.
http://manojc.com
"Karthik V" <[email protected]> wrote in message
news:[email protected]...
Manoj:
I do not understand how the runtime will strip the xml.
I think Anamitra's requirement of:
public void test(String poXML)
is very valid and a simple requirement.
Infact, my requirement too is similar..
1. Expose a method which takes in a String object.
2. Define how the String is going to look like (using xsd).
3. Instead of defining the schema in WSDL, we would like to import
the
schema and use it.
4. Later use the schema to validate the incoming request.
In real time most of us would like to work with String because ofits
simplicity.
Is there any reason why the implementation for such a simple usecase is
so
confusing?
/k
"manoj cheenath" <[email protected]> wrote in message
news:[email protected]...
public void test( String poXML )
is not the best solution for you, i think, because
in this case the runtime will strip the xml tags
inside poXML. so the envelope will look like:
<m:my-method>
<poXML>sdfjds >some thing < something else...</poXML>
</m:my-method>
instead of:
<m:my-method>
<poXML>some thing <foo> something else</foo></poXML>
</m:my-method>
Will that be ok for you? Else, you can use DOM or
javax.xml.soap.SOAPElement:
public void test( org.w3c.Dom poXML );
It looks like there is bug in WLS 7.0.2. The CR for this
is CR104719. Please contact support if you need a patch.
If you do clientgen on the WSDL, it is going to generate
the classes (value types) for you. It looks like you do not
want to do data binding. Take a look at DII client with generic
type-mapping. Will this help you?
package examples.jaxrpc.call5;
import java.net.URL;
import javax.xml.soap.SOAPConstants;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Service;
import javax.xml.rpc.Call;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
import javax.xml.rpc.encoding.TypeMapping;
import javax.xml.rpc.encoding.TypeMappingRegistry;
import javax.xml.soap.SOAPElement;
import weblogic.webservice.encoding.GenericTypeMapping;
import weblogic.webservice.core.soap.SOAPElementImpl;
public class MSInterop{
public static void main( String[] args ) throws Exception{
//dont parse wsdl till we set the typemapping
System.setProperty( "weblogic.webservice.servicenamechecking",
"false" );
//create service factory
ServiceFactory factory = ServiceFactory.newInstance();
//define qnames
String targetNamespace = "http://soapinterop.org/";
QName serviceName = new QName( targetNamespace, "SimpleTest"
QName portName = new QName( targetNamespace, "SimpleTestSoap");
QName operationName = new QName( "http://soapinterop.org/",
"echoStruct" );
URL wsdlLocation = new URL(
"http://www.mssoapinterop.org/asmx/simple.asmx?WSDL" );
//create service
Service service = factory.createService( wsdlLocation,serviceName );
TypeMappingRegistry registry =
service.getTypeMappingRegistry();
>>>>>
registry.register( SOAPConstants.URI_NS_SOAP_ENCODING,
new GenericTypeMapping() );
//create call
Call call = service.createCall( portName, operationName );
//construct struct
SOAPElement elem = new SOAPElementImpl( "inputStruct", null,null );
elem.addChildElement( "varInt" ).addTextNode( "1" );
elem.addChildElement( "varString" ).addTextNode( "samplestring" );
elem.addChildElement( "varFloat" ).addTextNode( "2.2" );
System.out.println( elem );
try{
SOAPElement res = (SOAPElement)call.invoke(new Object[]{elem } );
System.out.println( res );
}catch( javax.xml.rpc.JAXRPCException e ){
e.printStackTrace();
e.getLinkedCause().printStackTrace();
Call echoFloat = service.createCall( portName,
new QName( "http://soapinterop.org/", "echoFloat" ) );
System.out.println( echoFloat.invoke( new Object[]{new
Float(100.0)} ) );
http://manojc.com
"Anamitra" <[email protected]> wrote in message
news:[email protected]...
Hi Bruce
I think the wsdl that you sent was very near to what I was
looking
for.
But I
would try to make the requirement more clear: The points below
are
listed
in order
of priority:
1>First and foremost I am looking to create a Webservice such
that
it
exposes
a method which takes in a java.lang.String
public void test(String poXML)
But in the WSDL I want to show the user the schema definition
for
the
po
XML.
And would desire that the Webservices framework do the schema
validation
of the
incoming xml. But I dont thing this works as the wsdl generated
always
says the
type is "xsd:string". So I started looking into the 2nd option:
2>Create a doc/literal type service and expose that method as:
public void test(POXMLBean poXML)
This generated the reqd schema in the wsdl level but the client
is
being
forced
to use the POXMLBean to invoke the method. I would ideally want
the
client
to
just deal with the XML of the pobean as described in the
generated
schema
definition.
For example the client using JAXRPC should be say doing the code
like
this:
String poXML = "<po> <order>000</order> </po>"
call.invoke(poXML").
Is this possible? I am not able to do this. My primary important
thing
is
that
the client has to deal with XML and not with anything else. The
client
shouldnot
have to deal with POXMLBean. This is what I am trying to acheive
and
not
able
to.
3> So that leaves me to the last option which is not that good:
ie I keep my original approach:
public void test(String poXML)
and somehow via wsdl:documentation say that the schema for this
poXML
is
this...
But I cannot change the type in the parameter poXML from
xs:string
right?
Bottom line is there any way for the client to pass string/byte[]
xml
data
to
the webservice - but still be able to look into the WSDL and
see
what
the
reqd
XML structure should be? I thought doc/literal should do it -
but
using
weblogic
I am not able to do it. Can u help me with this pls.
thanks
Anamitra
Bruce Stephens <[email protected]> wrote:
Hello,
See what you think of this example of using import. It seems
to
describe your exact use case:
http://www.ws-i.org/SampleApplications/SupplyChainManagement/2002-08/Retai
l
er.wsdl
(Disclaimer, anyone could have found this via public UDDI.)
The issue I believe that Anamitra sees is the gap between the
runtime
and the toolset.
Bruce
Anamitra wrote:
Hi Karthik
I am a bit confused as to what you mean when u say "import".
The
generated
webservices.xml
contains a <types> and a <type-mapping> element. I suppose
u r
asking
me to put
the xsd definition in the <types> section - right?
If the method is like this:
public String doit(String msg)
How do I attach the <xs:string> type "msg" to the actual
XML
schema
that I just
imported?
I dont know whether I am asking stupid questions or not -
but I
would
have ideall
liked to see my "msg" of type say "PurchaseOrder" which is
the
schema
that I imported.
And the external client should just be able to give the
"PurchaseOrder"
xml to
the Webservice and invoke the "doit" method.
Am I making any sense?
thanks
Anamitra
"Karthik V" <[email protected]> wrote:
I doubt if servicegen has any option for doing it
automatically.
You should manually edit web-services.xml and import thexsd.
/k
"Anamitra" <[email protected]> wrote in message
news:[email protected]...
Hi Karthik/Bruce
Can you pls explain to me how using weblogic tools
[servicegen]
one
can
include
the xsd pointers in the WSDL file.
We have a similar kind of requirement where we have
webservices
which
take
in
string [XML data] as a parameter and the WSDL only shows
method
parameter
types
as xsd:string - but we want to show something like a schema
definition.
So
if
there is anyway to put the schema definition in the WSDL
- pls
let
me know
that
would be very very helpful.
thanks
Anamitra
"Karthik V" <[email protected]> wrote:
Bruce,
Thanks for your response. That helped.
I have another question for you.
I know this would sound strange.
But my requirement is to expose a session bean method
that
could
take
different xml inputs.
For example:
TestBean exposes testMethod(String xmlstr)
xmlstr could be of schema xmlSchema1.xsd
or xmlstr could be of schema xmlSchema2.xsd
In future it could also represent xmlSchema3.xsd... and
so
on.
What is the right approach in this scenario?
I was thinking to create a different web service fordifferent
xsd.
Say, webservice1 imports xmlSchema1.xsd, webservice2
imports
xmlSchema2.xsd...
Un fortunately due to some design restrictions, I cannotcreate
different
methods in my session bean like testMethod1,
testMethod2....
Is there any other better way to do this in one webservice?
>>>>>>>>>>>
Thanks in advance for any suggestions. And excuse myunusual
requirement.
/k
"Bruce Stephens" <[email protected]> wrote in message
news:[email protected]...
Hello,
Personally I like to see everything in one place, i.e.
in
the
WSDL,
however everyone else :-) uses the import. The
SOAPBuilders
round
3
have several tests showing imports. Also WSI Basic
profile
has
some
helpful guidelines on using import:
http://www.ws-i.org/Profiles/Basic/2003-03/BasicProfile-1.0-BdAD.html
>>>>>>>>>>>>
HTHs,
Bruce
Karthik V wrote:
Hi,
I have created few doc style web services, with a
very
complex
xml
input
and
output. (1200 lines of xsd)
Input and out put are xml as java.lang.String.
What would be the best practice to represent this
in the
WSDL?
Just
a
reference to the xsd file is good, or should it be
completely
presented
within the WSDL? I'm not sure how my wsdl should look
like...
I will be using the same schema (xsd) in other web
services
too
to
perform
different functions.
Any suggestions would be greatly appreciated.
Thanks
/k
[testWSDL.wsdl]
[PO.xsd]Hello Karthik/Anamitra,
i have the same requirements in my webservices:
1) Expose the Handler method receiving String
public String runRequest(String poXML)
2) On the other hand - the message (the poXML string) should be in XML format according to some XSD file.
Have you got this working already?
If so, please explain what the WSDL looks like.
Thanks in advance,
Orly -
I have an ODSI Physical Service that is based on a Java Function. The Java Function builds a SQL statement and uses JDBC to query for a ResultSet. One of the columns that is queried is a Clob. Sometimes, the data in this column causes an XMLBeans validation exception in ODSI: {err}XQ0027: Validation failed: error: decimal: Invalid decimal value: unexpected char '114'
The issue is not consistently replicable with particular database record, the database records that present this issue at one point in time will be resolved after a restart of ODSI and replaced by another list of records that present the same error.
As can be seen from the stack trace, it looks like the issue is happening after the database query has returned and while the process is assembling the SOAP response.
Error at line:2 col:481 Line:2 '=' expected, got char[99]
at weblogic.xml.babel.scanner.ScannerState.expect(ScannerState.java:241)
at weblogic.xml.babel.scanner.OpenTag.read(OpenTag.java:60)
at weblogic.xml.babel.scanner.Scanner.startState(Scanner.java:251)
at weblogic.xml.babel.scanner.Scanner.scan(Scanner.java:178)
at weblogic.xml.babel.baseparser.BaseParser.accept(BaseParser.java:533)
at weblogic.xml.babel.baseparser.BaseParser.accept(BaseParser.java:510)
at weblogic.xml.babel.baseparser.EndElement.parse(EndElement.java:34)
at weblogic.xml.babel.baseparser.BaseParser.parseElement(BaseParser.java:457)
at weblogic.xml.babel.baseparser.BaseParser.parseSome(BaseParser.java:326)
at weblogic.xml.stax.XMLStreamReaderBase.advance(XMLStreamReaderBase.java:195)
at weblogic.xml.stax.XMLStreamReaderBase.next(XMLStreamReaderBase.java:237)
at weblogic.xml.stax.XMLEventReaderBase.parseSome(XMLEventReaderBase.java:189)
at weblogic.xml.stax.XMLEventReaderBase.nextEvent(XMLEventReaderBase.java:122)
at weblogic.xml.query.parsers.StAXEventAdaptor.queueNextTokens(StAXEventAdaptor.java:136)
at weblogic.xml.query.parsers.StAXEventAdaptor.queueNextTokens(StAXEventAdaptor.java:124)
at weblogic.xml.query.parsers.BufferedParser.fetchNext(BufferedParser.java:79)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.navigation.ChildPath.fetchNext(ChildPath.java:308)
at weblogic.xml.query.iterators.GenericIterator.hasNext(GenericIterator.java:133)
at weblogic.xml.query.schema.BestEffortValidatingIterator$OpenedIterator.hasNext(BestEffortValidatingIterator.java:224)
at weblogic.xml.query.schema.ValidatingIterator.fetchNext(ValidatingIterator.java:82)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.xdbc.iterators.ItemIterator.fetchNext(ItemIterator.java:86)
at weblogic.xml.query.iterators.LegacyGenericIterator.next(LegacyGenericIterator.java:109)
at weblogic.xml.query.schema.BestEffortValidatingIterator.fetchNext(BestEffortValidatingIterator.java:85)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.xdbc.iterators.ItemIterator.fetchNext(ItemIterator.java:86)
at weblogic.xml.query.iterators.LegacyGenericIterator.next(LegacyGenericIterator.java:109)
at weblogic.xml.query.runtime.typing.SeqTypeMatching.fetchNext(SeqTypeMatching.java:137)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at com.bea.dsp.wrappers.jf.JavaFunctionIterator.fetchNext(JavaFunctionIterator.java:273)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.querycide.QueryAssassin.fetchNext(QueryAssassin.java:54)
at weblogic.xml.query.iterators.GenericIterator.peekNext(GenericIterator.java:163)
at weblogic.xml.query.runtime.qname.InsertNamespaces.fetchNext(InsertNamespaces.java:247)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.core.ExecutionWrapper.fetchNext(ExecutionWrapper.java:88)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.xdbc.iterators.ItemIterator.fetchNext(ItemIterator.java:86)
at weblogic.xml.query.iterators.LegacyGenericIterator.hasNext(LegacyGenericIterator.java:130)
at weblogic.xml.query.xdbc.util.Serializer.serializeItems(Serializer.java:251)
at com.bea.ld.server.ResultPusher$DSP25CompatibilityPusher.next(ResultPusher.java:236)
at com.bea.ld.server.ResultPusher.pushResults(ResultPusher.java:112)
at com.bea.ld.server.XQueryInvocation.execute(XQueryInvocation.java:770)
at com.bea.ld.EJBRequestHandler.invokeQueryInternal(EJBRequestHandler.java:624)
at com.bea.ld.EJBRequestHandler.invokeOperationInternal(EJBRequestHandler.java:478)
at com.bea.ld.EJBRequestHandler.invokeOperation(EJBRequestHandler.java:323)
at com.bea.ld.ServerWrapperBean.invoke(ServerWrapperBean.java:153)
at com.bea.ld.ServerWrapperBean.invokeOperation(ServerWrapperBean.java:80)
at com.bea.ld.ServerWrapper_s9smk0_ELOImpl.invokeOperation(ServerWrapper_s9smk0_ELOImpl.java:63)
at com.bea.dsp.ws.RoutingHandler$PriviledgedRunner.run(RoutingHandler.java:96)
at com.bea.dsp.ws.RoutingHandler.handleResponse(RoutingHandler.java:217)
at weblogic.wsee.handler.HandlerIterator.handleResponse(HandlerIterator.java:287)
at weblogic.wsee.handler.HandlerIterator.handleResponse(HandlerIterator.java:271)
at weblogic.wsee.ws.dispatch.server.ServerDispatcher.dispatch(ServerDispatcher.java:176)
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:285)
at weblogic.wsee.server.servlet.BaseWSServlet.service(BaseWSServlet.java:169)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
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:292)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
<Apr 29, 2011 12:47:01 PM EDT> <Notice> <ODSI> <BEA-000000> <LabOrderDataServices> <Error occurred performing ODSI operation: {ld:LabOrder/logical/LabOrderReport}getLabOrderDetails:1
weblogic.xml.query.exceptions.XQueryDynamicException: ld:LabOrder/logical/LabOrderReport.ds, line 34, column 6: {err}FODC0002 [{bea-err}FODC0002a]: Error parsing input XML: Error at line:2 col:481 Line:2 '=' expected, got char[99]
at weblogic.xml.query.iterators.AbstractIterator.reportUserError(AbstractIterator.java:95)
at weblogic.xml.query.iterators.AbstractIterator.reportUserError(AbstractIterator.java:147)
at weblogic.xml.query.parsers.Parser.reportParseError(Parser.java:157)
at weblogic.xml.query.parsers.StAXEventAdaptor.queueNextTokens(StAXEventAdaptor.java:225)
at weblogic.xml.query.parsers.StAXEventAdaptor.queueNextTokens(StAXEventAdaptor.java:124)
Truncated. see log file for complete stacktrace
javax.xml.stream.XMLStreamException: Error at line:2 col:481 Line:2 '=' expected, got char[99]
at weblogic.xml.stax.XMLStreamReaderBase.advance(XMLStreamReaderBase.java:206)
at weblogic.xml.stax.XMLStreamReaderBase.next(XMLStreamReaderBase.java:237)
at weblogic.xml.stax.XMLEventReaderBase.parseSome(XMLEventReaderBase.java:189)
at weblogic.xml.stax.XMLEventReaderBase.nextEvent(XMLEventReaderBase.java:122)
at weblogic.xml.query.parsers.StAXEventAdaptor.queueNextTokens(StAXEventAdaptor.java:136)
Truncated. see log file for complete stacktrace
Error at line:2 col:481 Line:2 '=' expected, got char[99]
at weblogic.xml.babel.scanner.ScannerState.expect(ScannerState.java:241)
at weblogic.xml.babel.scanner.OpenTag.read(OpenTag.java:60)
at weblogic.xml.babel.scanner.Scanner.startState(Scanner.java:251)
at weblogic.xml.babel.scanner.Scanner.scan(Scanner.java:178)
at weblogic.xml.babel.baseparser.BaseParser.accept(BaseParser.java:533)
Truncated. see log file for complete stacktrace
>
Can somebody shed some light on this issue?
Thanks
Edited by: user738507 on May 6, 2011 7:21 AMHere is the java function:
* Iterate through the search results and build out the XmlBean response
* @param helper A helper class used to simplify common JDBC commands
* @param doc The XmlBean document to populate
* @param isCollectionsIncluded True if Collection info should be included in results, False otherwise
* @param isFullDetailsIncluded True if Result data should be included in results, False otherwise
* @throws Exception
private static void addOrders(XmlBeansJDBCHelper helper, LabOrderReportDocument doc,
boolean isCollectionsIncluded, boolean isFullDetailsIncluded) throws Exception {
int rows = 0;
ResultSet rs = helper.getResultSet();
LabOrders labOrders = doc.getLabOrderReport().addNewLabOrders();
LabOrder record = null;
HashMap<Long, Collection> parentCollectionMap = null;
// initialize variable used to track when child elements of the XML should be created
long previousRowOrderId = 0;
long previousRowParentOrderCollectionId = 0;
long previousRowOrderCollectionId = 0;
long previousRowResultId = 0;
boolean isRootCollectionNode = false;
LabOrder.Collections lastParentOuterCollectionsAdded = null;
com.idexx.services.lde.laborder.Collection.Collections lastParentInnerCollectionsAdded = null;
com.idexx.services.lde.laborder.Collection lastCollectionAdded = null;
Result lastResultAdded = null;
// Loop through the results and build XmlBean nodes for each row
// Since the SQL is joining Orders to Collections (one-to-many) to Results (one-to-many),
// and returning a flat structure, there will be duplicate Order data on each row when
// multiple collections exist on the Order, and duplicate Collection data when multiple
// Results exist. We can use this fact to determine when to create a new Collection, or
// Result node.
while (helper.getResultSet().next())
rows++;
long currentRowParentOrderCollectionId = 0;
long currentRowOrderCollectionId = 0;
long currentRowResultId = 0;
long currentRowResultRemarkId = 0;
//int rowno = helper.getResultSet().getRow();
// Get the Order ID
logDebug("Getting the OrderId.....");
BigInteger dbOrderId = JDBCHelper.getBigInteger(rs, DataConstants.ORDER_ID);
logDebug("DONE getting the OrderId.");
long currentRowOrderId = dbOrderId.longValue();
// Determine the Order ID, Order Collection ID, and Result ID currently being processed.
// These will be used to determine whether to start a new LabOrder Bean, Collections Bean, or Results Bean
if (isCollectionsIncluded || isFullDetailsIncluded) {
// Get the ParentOrderCollectionID
logDebug("Getting the Parent Collection Order ID.....");
BigInteger dbParentOrderCollectionId = JDBCHelper.getBigInteger(rs, DataConstants.PARENT_ORDER_COLLECTION_ID);
if ( dbParentOrderCollectionId != null )
currentRowParentOrderCollectionId = dbParentOrderCollectionId.longValue();
else
currentRowParentOrderCollectionId = 0;
// Get the OrderCollectionID
logDebug("Getting the Order Collection ID.....");
BigInteger dbOrderCollectionId = JDBCHelper.getBigInteger(rs, DataConstants.ORDER_COLLECTION_ID);
if ( dbOrderCollectionId != null )
currentRowOrderCollectionId = dbOrderCollectionId.longValue();
else
currentRowOrderCollectionId = 0;
if ( isFullDetailsIncluded ) {
// Get the ResultID
logDebug("Getting the Result Id.....");
BigInteger dbResultId = JDBCHelper.getBigInteger(rs, DataConstants.RESULT_ID);
if ( dbResultId != null )
currentRowResultId = dbResultId.longValue();
else
currentRowResultId = 0;
// Get the ResultRemarkID
BigInteger dbResultRemarkId = JDBCHelper.getBigInteger(rs, DataConstants.RESULT_REMARK_ID);
if ( dbResultRemarkId != null )
currentRowResultRemarkId = dbResultRemarkId.longValue();
else
currentRowResultRemarkId = 0;
isRootCollectionNode = (currentRowParentOrderCollectionId == 0);
logDebug("currentRowOrderId: " + currentRowOrderId);
logDebug("previousRowOrderId: " + previousRowOrderId);
logDebug("currentRowResultId: " + currentRowResultId);
logDebug("previousRowResultId: " + previousRowResultId);
logDebug("currentRowResultRemarkId: " + currentRowResultRemarkId);
logDebug("previousRowResultRemarkId: N/A");
logDebug("currentRowParentOrderCollectionId: " + currentRowParentOrderCollectionId);
logDebug("previousRowParentOrderCollectionId: " + previousRowParentOrderCollectionId);
logDebug("currentRowOrderCollectionId: " + currentRowOrderCollectionId);
logDebug("previousRowOrderCollectionId: " + previousRowOrderCollectionId);
if ( currentRowOrderId != previousRowOrderId ) {
parentCollectionMap = new HashMap<Long, Collection>();
lastParentOuterCollectionsAdded = null;
lastParentInnerCollectionsAdded = null;
lastCollectionAdded = null;
lastResultAdded = null;
// This is a new Order, generate a new Lab Order bean
record = addOrder(labOrders, helper, dbOrderId, isFullDetailsIncluded);
logDebug("Order Added!");
// If there is Parent Collection data and it should be included, build a Collections element,
// and populate the first one
if ( !isRootCollectionNode && (isCollectionsIncluded || isFullDetailsIncluded) ) {
lastParentOuterCollectionsAdded = record.addNewCollections();
lastCollectionAdded = addCollection(record, helper, lastParentOuterCollectionsAdded, true);
logDebug("Collection Added! Is it null? " + (lastCollectionAdded == null));
// If there is Collection data and it should be included, build a Collections element,
// and populate the first one
if ( currentRowOrderCollectionId > 0 && (isCollectionsIncluded || isFullDetailsIncluded) ) {
if ( isRootCollectionNode ) {
lastParentOuterCollectionsAdded = record.addNewCollections();
lastCollectionAdded = addCollection(record, helper, lastParentOuterCollectionsAdded, false);
parentCollectionMap.put(new Long(currentRowOrderCollectionId), lastCollectionAdded);
logDebug("parent collection added to map: " + currentRowOrderCollectionId);
else {
lastParentInnerCollectionsAdded = lastCollectionAdded.addNewCollections();
lastCollectionAdded = addCollection(record, helper, lastParentInnerCollectionsAdded, false);
logDebug("Collection Added! Is it null? " + (lastCollectionAdded == null));
// If there is Result data and it should be included, build a Results element,
// and populate the first one
if ( currentRowResultId > 0 && isFullDetailsIncluded ) {
logDebug("Adding result....");
lastResultAdded = addResult(record, helper, lastCollectionAdded);
logDebug("Result Added!");
// If there is Result Remark data and it should be included, build a ResultRemarks element,
// and populate the first one
if ( currentRowResultRemarkId > 0 && isFullDetailsIncluded ) {
addResultRemark(record, helper, lastResultAdded);
logDebug("DONE getting first Collection and Result.");
else if ( currentRowParentOrderCollectionId != previousRowParentOrderCollectionId
&& (isCollectionsIncluded || isFullDetailsIncluded) ) {
// This is a new, top level, Order Collection to be included
lastParentOuterCollectionsAdded = null;
lastParentInnerCollectionsAdded = null;
lastCollectionAdded = null;
lastResultAdded = null;
logDebug("Getting next Order Collection...");
// If there is Parent Collection data and it should be included, build a Collections element,
// and populate the first one
if ( !isRootCollectionNode ) {
lastCollectionAdded = (com.idexx.services.lde.laborder.Collection)parentCollectionMap.get(new Long(currentRowParentOrderCollectionId));
logDebug("A Collection Added! Is it null? " + (lastCollectionAdded == null));
// If there is Collection data and it should be included, build a Collections element,
// and populate the first one
if ( currentRowOrderCollectionId > 0 ) {
if ( isRootCollectionNode ) {
//LabOrder.Collections collections = record.addNewCollections();
lastParentOuterCollectionsAdded = record.getCollections();
lastCollectionAdded = addCollection(record, helper, lastParentOuterCollectionsAdded, false);
parentCollectionMap.put(new Long(currentRowOrderCollectionId), lastCollectionAdded);
else {
lastParentInnerCollectionsAdded = lastCollectionAdded.addNewCollections();
lastCollectionAdded = addCollection(record, helper, lastParentInnerCollectionsAdded, false);
logDebug("B Collection Added! Is it null? " + (lastCollectionAdded == null));
// If there is Result data and it should be included, build a Results element,
// and populate the first one
if ( currentRowResultId > 0 && isFullDetailsIncluded ) {
lastResultAdded = addResult(record, helper, lastCollectionAdded);
// If there is Result Remark data and it should be included, build a ResultRemarks element,
// and populate the first one
if ( currentRowResultRemarkId > 0 && isFullDetailsIncluded ) {
addResultRemark(record, helper, lastResultAdded);
else if ( currentRowOrderCollectionId != previousRowOrderCollectionId
&& (isCollectionsIncluded || isFullDetailsIncluded) ) {
// This is a new Order Collection to be included inside of a parent collection
logDebug("Getting next CHILD Order Collection...");
logDebug("isRootCollectionNode: " + isRootCollectionNode);
logDebug("Order ID: " + helper.getBigInteger(DataConstants.ORDER_ID));
logDebug("Order Collection ID: " + helper.getBigInteger(DataConstants.ORDER_COLLECTION_ID));
logDebug("Collection ID: " + helper.getBigInteger(DataConstants.COLLECTION_ID));
if ( isRootCollectionNode ) {
lastCollectionAdded = addCollection(record, helper, lastParentOuterCollectionsAdded, false);
parentCollectionMap.put(new Long(currentRowOrderCollectionId), lastCollectionAdded);
else {
com.idexx.services.lde.laborder.Collection parentCollection = (com.idexx.services.lde.laborder.Collection)parentCollectionMap.get(new Long(currentRowParentOrderCollectionId));
if(parentCollection == null) {
log(LOG_LEVEL.WARN, "Parent Collection with id: " + currentRowParentOrderCollectionId + " is null for collection id: " + currentRowOrderCollectionId + " but isRootCollectionNode is " + isRootCollectionNode);
} else {
lastParentInnerCollectionsAdded = parentCollection.getCollections();
logDebug("Is lastParentInnerCollectionsAdded null? " + (lastParentInnerCollectionsAdded == null));
lastCollectionAdded = addCollection(record, helper, lastParentInnerCollectionsAdded, false);
// If there is Result data and it should be included, build a Results element,
// and populate the first one
if ( currentRowResultId > 0 && isFullDetailsIncluded ) {
lastResultAdded = addResult(record, helper, lastCollectionAdded);
// If there is Result Remark data and it should be included, build a ResultRemarks element,
// and populate the first one
if ( currentRowResultRemarkId > 0 && isFullDetailsIncluded ) {
addResultRemark(record, helper, lastResultAdded);
else if ( currentRowResultId != previousRowResultId
&& isFullDetailsIncluded ) {
// There is a new Result to be included
logDebug("Getting next Result...");
// This is a new result to be included
lastResultAdded = addResult(record, helper, lastCollectionAdded);
// If there is Result Remark data and it should be included, build a ResultRemarks element,
// and populate the first one
if ( currentRowResultRemarkId > 0 && isFullDetailsIncluded ) {
addResultRemark(record, helper, lastResultAdded);
else if ( isFullDetailsIncluded ) {
// There is a new Result Remark to include
logDebug("Getting next Result Remark...");
// This is a new result remark to be included
addResultRemark(record, helper, lastResultAdded);
logDebug("Done building response.");
previousRowResultId = currentRowResultId;
previousRowParentOrderCollectionId = currentRowParentOrderCollectionId;
previousRowOrderCollectionId = currentRowOrderCollectionId;
previousRowOrderId = currentRowOrderId;
logDebug("Found " + rows + " rows of data.");
} -
Hi,
I have created few doc style web services, with a very complex xml input and
output. (1200 lines of xsd)
Input and out put are xml as java.lang.String.
What would be the best practice to represent this in the WSDL? Just a
reference to the xsd file is good, or should it be completely presented
within the WSDL? I'm not sure how my wsdl should look like...
I will be using the same schema (xsd) in other web services too to perform
different functions.
Any suggestions would be greatly appreciated.
Thanks
/kHi karthik
I still dont get how the poXML can be represented by a schema in a WSDL. Can you
give me a sample wsdl for that?
Thanks
Anamitra
"Karthik V" <[email protected]> wrote:
Manoj:
Sorry, I got confused when you said, "the runtime will strip the xml
tags".
After your explanation, I understand that the runtime is actually going
to
perform some conversion without any loss of data.
To conclude, logically,
public void test(String poXML) is valid, and poXML can be represented
by
a schema definition.
When I get a chance, I'm going to create a quick example of this use
case
and post it.
Thanks,
/k
"manoj cheenath" <[email protected]> wrote in message
news:[email protected]...
java.lang.String is mapped to xsd:string which means the xml
should look like:
<foo xsi:type=xsd:string >sometext without any xml tags</foo>
So if there are xml tags inside the string you passed
in, runtime need to replace the tags with > and
<.
On the other end the runtime will again replace
etc back to < or >. So you will get back theright XML. But on the wire it will be plain text
not XML.
So, if you dont want to convert to string, then you should use
javax.xml.soap.SOAPElement or org.w3c.Element as
your parameter type instead of java.lang.String.
http://manojc.com
"Karthik V" <[email protected]> wrote in message
news:[email protected]...
Manoj:
I do not understand how the runtime will strip the xml.
I think Anamitra's requirement of:
public void test(String poXML)
is very valid and a simple requirement.
Infact, my requirement too is similar..
1. Expose a method which takes in a String object.
2. Define how the String is going to look like (using xsd).
3. Instead of defining the schema in WSDL, we would like to import
the
schema and use it.
4. Later use the schema to validate the incoming request.
In real time most of us would like to work with String because ofits
simplicity.
Is there any reason why the implementation for such a simple usecase is
so
confusing?
/k
"manoj cheenath" <[email protected]> wrote in message
news:[email protected]...
public void test( String poXML )
is not the best solution for you, i think, because
in this case the runtime will strip the xml tags
inside poXML. so the envelope will look like:
<m:my-method>
<poXML>sdfjds >some thing < something else...</poXML>
</m:my-method>
instead of:
<m:my-method>
<poXML>some thing <foo> something else</foo></poXML>
</m:my-method>
Will that be ok for you? Else, you can use DOM or
javax.xml.soap.SOAPElement:
public void test( org.w3c.Dom poXML );
It looks like there is bug in WLS 7.0.2. The CR for this
is CR104719. Please contact support if you need a patch.
If you do clientgen on the WSDL, it is going to generate
the classes (value types) for you. It looks like you do not
want to do data binding. Take a look at DII client with generic
type-mapping. Will this help you?
package examples.jaxrpc.call5;
import java.net.URL;
import javax.xml.soap.SOAPConstants;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Service;
import javax.xml.rpc.Call;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
import javax.xml.rpc.encoding.TypeMapping;
import javax.xml.rpc.encoding.TypeMappingRegistry;
import javax.xml.soap.SOAPElement;
import weblogic.webservice.encoding.GenericTypeMapping;
import weblogic.webservice.core.soap.SOAPElementImpl;
public class MSInterop{
public static void main( String[] args ) throws Exception{
//dont parse wsdl till we set the typemapping
System.setProperty( "weblogic.webservice.servicenamechecking",
"false" );
//create service factory
ServiceFactory factory = ServiceFactory.newInstance();
//define qnames
String targetNamespace = "http://soapinterop.org/";
QName serviceName = new QName( targetNamespace, "SimpleTest"
QName portName = new QName( targetNamespace, "SimpleTestSoap");
QName operationName = new QName( "http://soapinterop.org/",
"echoStruct" );
URL wsdlLocation = new URL(
"http://www.mssoapinterop.org/asmx/simple.asmx?WSDL" );
//create service
Service service = factory.createService( wsdlLocation,serviceName );
TypeMappingRegistry registry = service.getTypeMappingRegistry();
registry.register( SOAPConstants.URI_NS_SOAP_ENCODING,
new GenericTypeMapping() );
//create call
Call call = service.createCall( portName, operationName );
//construct struct
SOAPElement elem = new SOAPElementImpl( "inputStruct", null,
null );
elem.addChildElement( "varInt" ).addTextNode( "1" );
elem.addChildElement( "varString" ).addTextNode( "samplestring" );
elem.addChildElement( "varFloat" ).addTextNode( "2.2" );
System.out.println( elem );
try{
SOAPElement res = (SOAPElement)call.invoke(new Object[]{elem } );
System.out.println( res );
}catch( javax.xml.rpc.JAXRPCException e ){
e.printStackTrace();
e.getLinkedCause().printStackTrace();
Call echoFloat = service.createCall( portName,
new QName( "http://soapinterop.org/", "echoFloat" ) );
System.out.println( echoFloat.invoke( new Object[]{new
Float(100.0)} ) );
http://manojc.com
"Anamitra" <[email protected]> wrote in message
news:[email protected]...
Hi Bruce
I think the wsdl that you sent was very near to what I was looking
for.
But I
would try to make the requirement more clear: The points below
are
listed
in order
of priority:
1>First and foremost I am looking to create a Webservice such
that
it
exposes
a method which takes in a java.lang.String
public void test(String poXML)
But in the WSDL I want to show the user the schema definition
for
the
po
XML.
And would desire that the Webservices framework do the schema
validation
of the
incoming xml. But I dont thing this works as the wsdl generated
always
says the
type is "xsd:string". So I started looking into the 2nd option:
2>Create a doc/literal type service and expose that method as:
public void test(POXMLBean poXML)
This generated the reqd schema in the wsdl level but the client
is
being
forced
to use the POXMLBean to invoke the method. I would ideally want
the
client
to
just deal with the XML of the pobean as described in the generated
schema
definition.
For example the client using JAXRPC should be say doing the code
like
this:
String poXML = "<po> <order>000</order> </po>"
call.invoke(poXML").
Is this possible? I am not able to do this. My primary important
thing
is
that
the client has to deal with XML and not with anything else. The
client
shouldnot
have to deal with POXMLBean. This is what I am trying to acheive
and
not
able
to.
3> So that leaves me to the last option which is not that good:
ie I keep my original approach:
public void test(String poXML)
and somehow via wsdl:documentation say that the schema for this
poXML
is
this...
But I cannot change the type in the parameter poXML from xs:string
right?
Bottom line is there any way for the client to pass string/byte[]
xml
data
to
the webservice - but still be able to look into the WSDL and
see
what
the
reqd
XML structure should be? I thought doc/literal should do it -
but
using
weblogic
I am not able to do it. Can u help me with this pls.
thanks
Anamitra
Bruce Stephens <[email protected]> wrote:
Hello,
See what you think of this example of using import. It seems
to
describe your exact use case:
http://www.ws-i.org/SampleApplications/SupplyChainManagement/2002-08/Retail
er.wsdl
(Disclaimer, anyone could have found this via public UDDI.)
The issue I believe that Anamitra sees is the gap between the
runtime
and the toolset.
Bruce
Anamitra wrote:
Hi Karthik
I am a bit confused as to what you mean when u say "import".
The
generated
webservices.xml
contains a <types> and a <type-mapping> element. I suppose
u r
asking
me to put
the xsd definition in the <types> section - right?
If the method is like this:
public String doit(String msg)
How do I attach the <xs:string> type "msg" to the actual
XML
schema
that I just
imported?
I dont know whether I am asking stupid questions or not -
but I
would
have ideall
liked to see my "msg" of type say "PurchaseOrder" which is
the
schema
that I imported.
And the external client should just be able to give the
"PurchaseOrder"
xml to
the Webservice and invoke the "doit" method.
Am I making any sense?
thanks
Anamitra
"Karthik V" <[email protected]> wrote:
I doubt if servicegen has any option for doing it automatically.
You should manually edit web-services.xml and import the
xsd.
/k
"Anamitra" <[email protected]> wrote in message
news:[email protected]...
Hi Karthik/Bruce
Can you pls explain to me how using weblogic tools
[servicegen]
one
can
include
the xsd pointers in the WSDL file.
We have a similar kind of requirement where we have
webservices
which
take
in
string [XML data] as a parameter and the WSDL only shows
method
parameter
types
as xsd:string - but we want to show something like a schema
definition.
So
if
there is anyway to put the schema definition in the WSDL
- pls
let
me know
that
would be very very helpful.
thanks
Anamitra
"Karthik V" <[email protected]> wrote:
Bruce,
Thanks for your response. That helped.
I have another question for you.
I know this would sound strange.
But my requirement is to expose a session bean method
that
could
take
different xml inputs.
For example:
TestBean exposes testMethod(String xmlstr)
xmlstr could be of schema xmlSchema1.xsd
or xmlstr could be of schema xmlSchema2.xsd
In future it could also represent xmlSchema3.xsd... and
so
on.
What is the right approach in this scenario?
I was thinking to create a different web service fordifferent
xsd.
Say, webservice1 imports xmlSchema1.xsd, webservice2 imports
xmlSchema2.xsd...
Un fortunately due to some design restrictions, I cannot
create
different
methods in my session bean like testMethod1, testMethod2....
Is there any other better way to do this in one web service?
Thanks in advance for any suggestions. And excuse my unusual
requirement.
/k
"Bruce Stephens" <[email protected]> wrote in message
news:[email protected]...
Hello,
Personally I like to see everything in one place, i.e.
in
the
WSDL,
however everyone else :-) uses the import. The
SOAPBuilders
round
3
have several tests showing imports. Also WSI Basic
profile
has
some
helpful guidelines on using import:
http://www.ws-i.org/Profiles/Basic/2003-03/BasicProfile-1.0-BdAD.html
HTHs,
Bruce
Karthik V wrote:
Hi,
I have created few doc style web services, with a
very
complex
xml
input
and
output. (1200 lines of xsd)
Input and out put are xml as java.lang.String.
What would be the best practice to represent this
in the
WSDL?
Just
a
reference to the xsd file is good, or should it be
completely
presented
within the WSDL? I'm not sure how my wsdl should look
like...
I will be using the same schema (xsd) in other web
services
too
to
perform
different functions.
Any suggestions would be greatly appreciated.
Thanks
/k -
Not able to run validation using validation.xml & validator-rules.xml
Hello Friends,
I am not able to run validation using validation.xml & validator-rules.xml.
Entire code in running prefectly but no error messages are prompted.
Following is my code:
File Name : struts-config.xml
<struts-config>
<!-- Form Beans Configuration -->
<form-beans>
<form-bean name="searchForm"
type="com.solversa.SearchForm"/>
</form-beans>
<!-- Global Forwards Configuration -->
<global-forwards>
<forward name="search" path="/search.jsp"/>
</global-forwards>
<!-- Action Mappings Configuration -->
<action-mappings>
<action path="/search"
type="com.solversa.SearchAction"
name="searchForm"
scope="request"
validate="true"
input="/search.jsp">
</action>
</action-mappings>
<!-- Message Resources Configuration -->
<message-resources
parameter="ApplicationResources"/>
<!-- Validator Configuration -->
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,
/WEB-INF/validation.xml"/>
</plug-in>
</struts-config>
<br> File Name : <b> validation.xml </b>
<form-validation>
<formset>
<form name="searchForm">
<field property="name" depends="minlength">
<arg key="label.search.name" position = "0"/>
<arg1 name="minlength" key="${var:minlength}" resource="false"/>
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>
</field>
<field property="ssNum" depends="mask">
<arg0 key="label.search.ssNum"/>
<var>
<var-name>mask</var-name>
<var-value>^\d{3}-\d{2}-\d{4}$</var-value>
</var>
</field>
</form>
</formset>
</form-validation>
<br> File Name : <b> SearchForm.java </b>
package com.jamesholmes.minihr;
import java.util.List;
import org.apache.struts.validator.ValidatorForm;
public class SearchForm extends ValidatorForm
private String name = null;
private String ssNum = null;
private List results = null;
public void setName(String name) {
this.name = name;
public String getName() {
return name;
public void setSsNum(String ssNum) {
this.ssNum = ssNum;
public String getSsNum() {
return ssNum;
public void setResults(List results) {
this.results = results;
public List getResults() {
return results;
<br> File Name : <b> SearchAction.java </b>
package com.jamesholmes.minihr;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public final class SearchAction extends Action
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
EmployeeSearchService service = new EmployeeSearchService();
ArrayList results;
SearchForm searchForm = (SearchForm) form;
// Perform employee search based on what criteria was entered.
String name = searchForm.getName();
if (name != null && name.trim().length() > 0) {
results = service.searchByName(name);
} else {
results = service.searchBySsNum(searchForm.getSsNum().trim());
// Place search results in SearchForm for access by JSP.
searchForm.setResults(results);
// Forward control to this Action's input page.
return mapping.getInputForward();
<br> File Name : <b> EmployeeSearchService.java </b>
package com.jamesholmes.minihr;
import java.util.ArrayList;
public class EmployeeSearchService
/* Hard-coded sample data. Normally this would come from a real data
source such as a database. */
private static Employee[] employees =
new Employee("Bob Davidson", "123-45-6789"),
new Employee("Mary Williams", "987-65-4321"),
new Employee("Jim Smith", "111-11-1111"),
new Employee("Beverly Harris", "222-22-2222"),
new Employee("Thomas Frank", "333-33-3333"),
new Employee("Jim Davidson", "444-44-4444")
// Search for employees by name.
public ArrayList searchByName(String name) {
ArrayList resultList = new ArrayList();
for (int i = 0; i < employees.length; i++) {
if (employees.getName().toUpperCase().indexOf(name.toUpperCase()) != -1) {
resultList.add(employees[i]);
return resultList;
// Search for employee by social security number.
public ArrayList searchBySsNum(String ssNum) {
ArrayList resultList = new ArrayList();
for (int i = 0; i < employees.length; i++) {
if (employees[i].getSsNum().equals(ssNum)) {
resultList.add(employees[i]);
return resultList;
<br> File Name : <b> Employee.java </b>
package com.solversa;
public class Employee
private String name;
private String ssNum;
public Employee(String name, String ssNum) {
this.name = name;
this.ssNum = ssNum;
public void setName(String name) {
this.name = name;
public String getName() {
return name;
public void setSsNum(String ssNum) {
this.ssNum = ssNum;
public String getSsNum() {
return ssNum;
Pls help me out.
Not able to prompt errors.Hello Friends,
I am not able to run validation using
validation.xml & validator-rules.xml.
Entire code in running prefectly but no error
messages are prompted.
Following is my code:
File Name : struts-config.xml
<struts-config>
<!-- Form Beans Configuration -->
<form-beans>
<form-bean name="searchForm"
type="com.solversa.SearchForm"/>
ans>
<!-- Global Forwards Configuration -->
<global-forwards>
<forward name="search" path="/search.jsp"/>
global-forwards>
<!-- Action Mappings Configuration -->
<action-mappings>
<action path="/search"
type="com.solversa.SearchAction"
name="searchForm"
scope="request"
validate="true"
input="/search.jsp">
tion>
</action-mappings>
<!-- Message Resources Configuration -->
<message-resources
parameter="ApplicationResources"/>
<!-- Validator Configuration -->
<plug-in
className="org.apache.struts.validator.ValidatorPlugI
">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,
/WEB-INF/validation.xml"/>
>
</struts-config>
<br> File Name : <b> validation.xml </b>
<form-validation>
<formset>
<form name="searchForm">
<field property="name" depends="minlength">
<arg key="label.search.name" position = "0"/>
<arg1 name="minlength" key="${var:minlength}"
resource="false"/>
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>
</field>
<field property="ssNum" depends="mask">
<arg0 key="label.search.ssNum"/>
<var>
<var-name>mask</var-name>
<var-value>^\d{3}-\d{2}-\d{4}$</var-value>
</var>
</field>
/form>
</formset>
form-validation>
<br> File Name : <b> SearchForm.java </b>
package com.jamesholmes.minihr;
import java.util.List;
import org.apache.struts.validator.ValidatorForm;
public class SearchForm extends ValidatorForm
private String name = null;
private String ssNum = null;
private List results = null;
public void setName(String name) {
this.name = name;
public String getName() {
return name;
public void setSsNum(String ssNum) {
this.ssNum = ssNum;
public String getSsNum() {
return ssNum;
public void setResults(List results) {
this.results = results;
public List getResults() {
return results;
<br> File Name : <b> SearchAction.java </b>
package com.jamesholmes.minihr;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public final class SearchAction extends Action
public ActionForward execute(ActionMapping
mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
EmployeeSearchService service = new
EmployeeSearchService();
ArrayList results;
SearchForm searchForm = (SearchForm) form;
// Perform employee search based on what criteria
was entered.
String name = searchForm.getName();
if (name != null && name.trim().length() > 0) {
results = service.searchByName(name);
else {
results =
service.searchBySsNum(searchForm.getSsNum().trim());
// Place search results in SearchForm for access
by JSP.
searchForm.setResults(results);
// Forward control to this Action's input page.
return mapping.getInputForward();
<br> File Name : <b> EmployeeSearchService.java </b>
package com.jamesholmes.minihr;
import java.util.ArrayList;
public class EmployeeSearchService
/* Hard-coded sample data. Normally this would come
from a real data
source such as a database. */
ivate static Employee[] employees =
new Employee("Bob Davidson", "123-45-6789"),
new Employee("Mary Williams", "987-65-4321"),
new Employee("Jim Smith", "111-11-1111"),
new Employee("Beverly Harris", "222-22-2222"),
new Employee("Thomas Frank", "333-33-3333"),
new Employee("Jim Davidson", "444-44-4444")
// Search for employees by name.
public ArrayList searchByName(String name) {
ArrayList resultList = new ArrayList();
for (int i = 0; i < employees.length; i++) {
if
(employees.getName().toUpperCase().indexOf(name.toU
pperCase()) != -1) {
resultList.add(employees[i]);
return resultList;
// Search for employee by social security number.
public ArrayList searchBySsNum(String ssNum) {
ArrayList resultList = new ArrayList();
for (int i = 0; i < employees.length; i++) {
if (employees[i].getSsNum().equals(ssNum)) {
resultList.add(employees[i]);
return resultList;
<br> File Name : <b> Employee.java </b>
package com.solversa;
public class Employee
private String name;
private String ssNum;
public Employee(String name, String ssNum) {
this.name = name;
this.ssNum = ssNum;
public void setName(String name) {
this.name = name;
public String getName() {
return name;
public void setSsNum(String ssNum) {
this.ssNum = ssNum;
public String getSsNum() {
return ssNum;
Pls help me out.
Not able to prompt errors.
Hi,
Your error message are not displaying because u does not made Message-Resoucrce property file (Resource Bundle) when you make it .
give it entry in
struts-config.xml
<message-resources parameter="ApplicationResources" />
and
define key and corresponding error message to key in this ApplicationResources i.e
#Error Resources
label.search.ssNum=Plz Enter correct ssNum -
Special characters in XML structure when prepared using String
Hi,
I am preparing an XML structure using 'String'. I print the prepared XML structure in the server log. Issue is that I am seeing extra characters([[ and ]]) that I am not printing.
Please let me know how to get rid of those.
Code Excerpt
String xmlHeader = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
String lsb_xmlcon = xmlHeader;
logger.info("ReqXMLString Process 1 --->" + lsb_xmlcon);
lsb_xmlcon = lsb_xmlcon +("\n");
logger.info("ReqXMLString Process 1.1 --->" + lsb_xmlcon);
lsb_xmlcon = lsb_xmlcon +("<REQUEST>");
lsb_xmlcon = lsb_xmlcon +("\n");
logger.info("ReqXMLString Process 1.2 --->" + lsb_xmlcon);
Log
ReqXMLString Process 1 ---><?xml version="1.0" encoding="utf-8" ?>
ReqXMLString Process 1.1 ---><?xml version="1.0" encoding="utf-8" ?>[[
ReqXMLString Process 1.2 ---><?xml version="1.0" encoding="utf-8" ?>[[
<REQUEST>
Thanks,
Message was edited by: 996913
This issue is observed only while running the code in server, not from Jdev.
When we append the additional tags without new line character, "\n", there are no extra characters being added. Also, in other case also. where we used "Marshaller" to prepare the XML, we have seen this issue.
After we set the below property to false, we got rid of the extra characters.
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
Apparently the insertion of new line when the code runs on server(Weblogic 10.3.6.0) is creating the issue.
Please let me know if anyone has come across a similar scenario.
Thanks,I am building this XML in a servlet so ,right, DOM does process XML (even though a valid HTML file can be loaded into a DOM object) but if you build XML using DOM then write the XML out using PrintWriter and Transformer objects this will cause the XML to print out in your browser. If you view source on this XML you will see that the DOM object has translated all special characters to there &xxxx; equivalent. For a example: when the string (I know "cool" java) gets loaded into a attribute using the DOM object then wrote back out it looks like (I know &xxx;cool&xxx; java) if you view the source in your browser. This is what it should do, but the DOM object is not change the � to the "&xxxxx;". This servlet is acting as a gateway between a Java API and a windows asp. The asp will call the servlet expecting to get XML back and load it directly into a DOM object. When the windows DOM object gets the xml that I am returning in this servlet is throws a exception "invalid character" because the � was not translated to &xxxx; like the other characters were. According to the book HTML 4 in 24 hours (and other references) the eacute; or #233; are how you say "�" in HTML or XML. How do you say it?
-
Convert IDOC XML structure to flat file - and now?
Hi,
we are working with input message ORDERS05 and want to convert it to flat file.
So we used the implementation description from "how to convert an IDOC-XML structure to a flat file....".
Looks like this is a standard procedure described here fitting for all IDOCs.
We followed the guide, making XI ready for Abap-Mapping, implemented the Abap class like described, added an interface mapping with source ORDERS05 to a mess.type dummy destination, added with type Abap-class the class implemented from the guide and completed the Int.Dir. implementation.
For comparism purpose we have two systems as receiver, one with a standard flat file with regular graph.mapping in XI, one with the Abap mapping.
Result:
Error description in SXMB_MONI:
Didn´t expect something like that! The IDOC was delivered successfully to the other simple flat file receiver.
Any idea what we made wrong (we are on SP17) or if there is a standard mistake you can do when following the guide?
Best regards
DirkHi,
I've got the same problem. He the solution in my case:
The problem is:
My IDOC has no element <STDMES>, but the method IF_MAPPING~EXECUTE from the 'HOW-TO Guide' does not check this situation:
el_element = idocument->find_from_name('STDMES').
ls_edidc-stdmes = el_element->get_value().
thows the exception.
Solution:
make shure that the field STDMESis set or change the method to:
el_element = idocument->find_from_name('STDMES').
if not el_element is initial.
ls_edidc-stdmes = el_element->get_value().
endif.
Best regards
Dieter -
How to change XML Structure from one form to another form using OO ABAP.
Hi Experts,
In my Scenario, i need to do ABAP Mapping in order to change Incoming structure from one form to another.
My Input to ABAP Mapping (OO ABAP Program)would be :
<A>..........</A>
<B>..........</B>
<C> .........</C>
<D>..........</D>
<E>..........</E>
<F>..........</F>
OO ABAP Program need to read this input and change the XML Structure into below form:
<A>..........</A>
<B>..........</B>
<C> .........</C>
<X>
<D>..........</D>
<E>..........</E>
<F>...............<F>
Please provide inputs (sample Code) to solve this issue.
Thanks,
Kish.
Edited by: Kishore Reddy Thamma on Jan 22, 2008 2:51 PM
Edited by: Kishore Reddy Thamma on Jan 22, 2008 2:52 PMHi,
Please provide sample code or Material for converting XML Structure from one form to another using OO ABAP and
Steps for ABAP MAPPING.
Thanks,
Kish. -
XSL to validate xml structure using XSD
Hi,
Can you please provide me a sample xsl that validates input XML against the given schema?
I have been trying with the following, but I am getting an error in jdeveloper 11g.
XML-23003: (Error) XPath 2.0 feature schema-element/schema-attribute not supported
Process exited with exit code 1.
<?xml version="1.0" encoding="windows-1252" ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import-schema schema-location="po1.xsd"/>
<xsl:output method="xml" version="1.0" indent="yes"/>
<!-- Root template -->
<xsl:template match="/">
<xsl:if test="not(* instance of schema-element(authorising))">
<xsl:message terminate="yes">
Source document is not a validated Provisioning list
</xsl:message>
</xsl:if>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
Thanks
923344Hi,
Can you please provide me a sample xsl that validates input XML against the given schema?
I have been trying with the following, but I am getting an error in jdeveloper 11g.
XML-23003: (Error) XPath 2.0 feature schema-element/schema-attribute not supported
Process exited with exit code 1.
<?xml version="1.0" encoding="windows-1252" ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import-schema schema-location="po1.xsd"/>
<xsl:output method="xml" version="1.0" indent="yes"/>
<!-- Root template -->
<xsl:template match="/">
<xsl:if test="not(* instance of schema-element(authorising))">
<xsl:message terminate="yes">
Source document is not a validated Provisioning list
</xsl:message>
</xsl:if>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
Thanks
923344 -
How to create an xml structure in webdynpro for java using NWDS?
Hi Experts,
I need to call an webservice by passing an xml structure to the webservice.I have the input values loaded on the context,which are basically tied to an Form UI element.Is there anyway in webdynpro to build an xml structure. ,
or do i need to use any open source like JAAS or DOM parser in the webdynpro project.?
Thanks
Aravindhi,
I was working on exporting table data from wd to Excel sheet. There, i had to create an XML representaion of the context.
Please refer to link, and go through page, 10 and 11 and see id you find anything useful.
[https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-technology/webdynpro/wd%20java/wdjava%20archive/exporting%20context%20data%20into%20excel%20using%20the%20web%20dynpro%20binary%20cache.pdf] -
Read input XML Payload in Mapping Program.
Hi all,
How can we access the input source XML structure in mapping program?
Please help me out in this?
Thanks and regards,
Kanth.Hi,
yes - how else would we be able to manipulate it ? (map it?)
if you want the whole payload (in "string") for example
you need to use java or abap mappings
if I understand your question correctly
Regards,
michal
<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a> -
Generating Dynamic UI from XML structure
Hi All,
I have a requirement in which I need to select an entry in the first view and based on this, the second view would come come. But there are 30 different values that can be selected and each of them will have a different set of UI elements in the second screen. So if I go for normal static UI creation, then I need to create 30 odd views which is something we do not want.
The second option is to dynamically generate the UI elements in wdDoModify() method. But for 30 different conditions to check all the time will lead to performance issue.
So we are thinking if there is a way for webdynpro to dynamically read an XML structure that defines attributes and generates a layout for us dynamically.
Please provide your inputs on this. Also kindly suggest any other better ways for the solution.
Thanks and Regards,
Sayan GhoshHello!
I think you should go with second one. But I don't know any "ready to use" solutions, so you have to
- Create your own XML structure, something like
<section type="yourCondition">
<input name="somePropertyName" type="text"/>
<!-- and so on -->
</section>
- Parse this XML into Java Model (on application startup for example)
- On user selection choose requred UI Model from memory and pass it to view
- In wdDoModify() build UI(elements, context attributes, mappings etc.) according to this model
It will be rather complicated for huge UI, but possible.
Thanks, Mikhail -
Can biztalk accept input xml with extra tags in it? if yes, How?
I have the following sample input xml:
<Students Class='xyz'>
<Student count='0'>
<FName value='Alex'/>
<LName value='James'>
<Age value='22'>
<DOB value='01/01/2001'>
<ID value='123'>
</Student>
<Student count='1'>
<FName value='Victor'/>
<LName value='Brown'>
<Age value='23'>
<DOB value='02/12/2000'>
<ID value='541'>
</Student>
</Students>
And my input schema accepts the xml which is similar to the above xml except it does not have <Age> and <DOB> tags in it. which means that the <Age> and <DOB> tags are extra tags in my input xml which is not
required by the input schema.
Question: is it possible in biztalk to accept the above xml as it is (i.e. along with <Age> and <DOB> tags) to populate the schema which accepts all xml except <Age> and <DOB> tags?
Can it just pick up the required tags and populate the input schema?
Thanks
manibestAutomatic change in the published schema on the basis of a received messages is still science fiction :)
There is still a way for you to handle these messages. If in the receive pipeline you do not enforce schema validation, in your orchestration you use bound receive ports [not direct ports] and receive the message as an XMLDocument, you should still be able
to receive/process the document.
The ability of an predefined Schema to accept additional data elements is called an OPEN CONTENT Model [refer
http://msdn.microsoft.com/en-us/library/aa468557.aspx] and you can create a schema to support such things if that is how you expect messages. So in your schema you define elements of type
"xsd:any" to accept content changes even with schema validation turned on.
Regards.
Maybe you are looking for
-
Multiple Apple ID's Want just one. Help
I have two apple ID's but I want to delete this one and set this email as the primary on the other one is there anyway to do that?
-
What would you use , golobal or local variabel ???
hello I must use an object that is going to use a sql connection to perform insert to database . this object is going to be used 4 times in my class is it better to use it a global variable ,or to create 4 times this object here is an example of the
-
Issues changing windows account password (RAC env) ??
Hi All, is there any issue changing password for windows account in an Oracle RAC environment? All services logs on as Local System account... Tks, Domenico. Edited by: user816046 on Jul 15, 2010 3:14 AM
-
Need help, iTunes bugging
When i try to play music on iTunes my music plays 2 or 3x faster than it should. Does anyone know how to fix this?
-
Hi OBIEE Guru's, Could any one can explain the time dimension. My requirement is :I have one DB table which contain the year column it is dimension table and another fact table contain the amount respective years,So I need to display records in a sin