XML Validation : isschemavalid always returns 0
Hello XML folks,
I have registered the schema and tried to validate. It always returns 0 (i.e invalid).
Could you please let me know what is wrong with XSD or XML
Thanks,
Parappa
SQL> DECLARE
2 doc varchar2(3800) :=
3 '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
4 <!--W3C Schema generated by XMLSpy v2005 sp1 U (http://www.xmlspy.com)-->
5 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:context="http://ibtco.com/common/exception/context" targetNamespace="http://ibtco.com/common/exception/context" elementFormDefault="qualified" attributeFormDefault="unqualified">
6 <xs:simpleType name="ContextValueType">
7 <xs:annotation>
8 <xs:documentation>data types for properties</xs:documentation>
9 </xs:annotation>
10 <xs:restriction base="xs:string">
11 <xs:enumeration value="boolean"/>
12 <xs:enumeration value="char"/>
13 <xs:enumeration value="byte"/>
14 <xs:enumeration value="int"/>
15 <xs:enumeration value="long"/>
16 <xs:enumeration value="float"/>
17 <xs:enumeration value="double"/>
18 <xs:enumeration value="decimal"/>
19 <xs:enumeration value="date"/>
20 <xs:enumeration value="time"/>
21 <xs:enumeration value="dateTime"/>
22 <xs:enumeration value="string"/>
23 </xs:restriction>
24 </xs:simpleType>
25 <xs:complexType name="ContextPropertyType">
26 <xs:annotation>
27 <xs:documentation>
28 for holding name/value pair for application data
29 </xs:documentation>
30 </xs:annotation>
31 <xs:simpleContent>
32 <xs:extension base="xs:string">
33 <xs:attribute name="Name" type="xs:Name" use="required"/>
34 <xs:attribute name="Type" type="context:ContextValueType" use="optional"/>
35 </xs:extension>
36 </xs:simpleContent>
37 </xs:complexType>
38 <xs:complexType name="ExceptionContextType">
39 <xs:annotation>
40 <xs:documentation>
41 for holding the data from applications
42 </xs:documentation>
43 </xs:annotation>
44 <xs:sequence>
45 <xs:element name="Property" type="context:ContextPropertyType" minOccurs="0" maxOccurs="unbounded"/>
46 </xs:sequence>
47 </xs:complexType>
48 <xs:element name="ExceptionContext" type="context:ExceptionContextType">
49 <xs:annotation>
50 <xs:documentation>
51 top level element exception context
52 </xs:documentation>
53 </xs:annotation>
54 </xs:element>
55 </xs:schema>';
56 BEGIN
57 dbms_xmlschema.registerSchema('http://ibtco.com/common/exception/context', doc);
58 END;
59 /
PL/SQL procedure successfully completed.
SQL> DECLARE
2
3 l_errormsgid VARCHAR2(30);
4 l_errorinfo VARCHAR2(100);
5 l_error_context CLOB; -- Error Stack
6 l_error_context_data CLOB; -- XML Context
7 l_var_xml_context VARCHAR2(4000);
8 l_var_error_stack VARCHAR2(4000);
9 l_sqlCode UTL_ERROR_LOGS.ERROR_CODE%TYPE;
10 p_ErrorMsgId NUMBER := '0';
11 p_ErrorInfo VARCHAR2(2000):= 'SUCCESS';
12 l_xml_context SYS.XMLTYPE;
13 l_count number :=0;
14 l_ret NUMBER;
15 BEGIN
16
17
18 -- Store XML in a clob
19 /*
20 l_var_xml_context := '<ExceptionContext>
21 <Property Name="Name1" Type="boolean">true</Property>
22 <Property Name="Name2" Type="string">String</Property>
23 </ExceptionContext>';
24 */
25
26 l_var_xml_context := '<?xml version="1.0" encoding="UTF-8"?>
27 <!--Sample XML file generated by XMLSpy v2005 sp1 U (http://www.xmlspy.com)-->
28 <ExceptionContext
29 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
30 xsi:schemaLocation="http://ibtco.com/common/exception/context"
31 >
32 <Property Name="Name1" Type="boolean">true</Property>
33 <Property Name="Name2" Type="string">String</Property>
34 </ExceptionContext>';
35
36 DBMS_LOB.CREATETEMPORARY
37 (
38 lob_loc => l_error_context_data,
39 cache => TRUE
40 );
41
42 DBMS_LOB.WRITE
43 (
44 lob_loc =>l_error_context_data,
45 amount => length(l_var_xml_context),
46 offset => 1,
47 buffer => l_var_xml_context
48 );
49
50 l_xml_context := XMLTYPE(l_error_context_data);
51
52
53 -- validate against XML schema
54 --l_xml_context.schemavalidate();
55 l_ret := l_xml_context.isschemavalid('"http://ibtco.com/common/exception/context"');
56 IF l_ret = 1 then
57 dbms_output.put_line('Data is valid:' || l_ret );
58 ELSE
59 dbms_output.put_line('Data is invalid:' || l_ret);
60 END IF;
61 END;
62 /
Data is invalid:0
PL/SQL procedure successfully completed.
SQL>
SQL>
Here is the script :
DECLARE
doc varchar2(3800) :=
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--W3C Schema generated by XMLSpy v2005 sp1 U (http://www.xmlspy.com)-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:context="http://ibtco.com/common/exception/context" targetNamespace="http://ibtco.com/common/exception/context" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:simpleType name="ContextValueType">
<xs:annotation>
<xs:documentation>data types for properties</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="boolean"/>
<xs:enumeration value="char"/>
<xs:enumeration value="byte"/>
<xs:enumeration value="int"/>
<xs:enumeration value="long"/>
<xs:enumeration value="float"/>
<xs:enumeration value="double"/>
<xs:enumeration value="decimal"/>
<xs:enumeration value="date"/>
<xs:enumeration value="time"/>
<xs:enumeration value="dateTime"/>
<xs:enumeration value="string"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="ContextPropertyType">
<xs:annotation>
<xs:documentation>
for holding name/value pair for application data
</xs:documentation>
</xs:annotation>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Name" type="xs:Name" use="required"/>
<xs:attribute name="Type" type="context:ContextValueType" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="ExceptionContextType">
<xs:annotation>
<xs:documentation>
for holding the data from applications
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="Property" type="context:ContextPropertyType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:element name="ExceptionContext" type="context:ExceptionContextType">
<xs:annotation>
<xs:documentation>
top level element exception context
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>';
BEGIN
dbms_xmlschema.registerSchema('http://ibtco.com/common/exception/context', doc);
END;
DECLARE
l_errormsgid VARCHAR2(30);
l_errorinfo VARCHAR2(100);
l_error_context CLOB; -- Error Stack
l_error_context_data CLOB; -- XML Context
l_var_xml_context VARCHAR2(4000);
l_var_error_stack VARCHAR2(4000);
l_sqlCode UTL_ERROR_LOGS.ERROR_CODE%TYPE;
p_ErrorMsgId NUMBER := '0';
p_ErrorInfo VARCHAR2(2000):= 'SUCCESS';
l_xml_context SYS.XMLTYPE;
l_count number :=0;
l_ret NUMBER;
BEGIN
-- Store XML in a clob
l_var_xml_context := '<ExceptionContext>
<Property Name="Name1" Type="boolean">true</Property>
<Property Name="Name2" Type="string">String</Property>
</ExceptionContext>';
l_var_xml_context := '<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSpy v2005 sp1 U (http://www.xmlspy.com)-->
<ExceptionContext
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ibtco.com/common/exception/context"
>
<Property Name="Name1" Type="boolean">true</Property>
<Property Name="Name2" Type="string">String</Property>
</ExceptionContext>';
DBMS_LOB.CREATETEMPORARY
lob_loc => l_error_context_data,
cache => TRUE
DBMS_LOB.WRITE
lob_loc =>l_error_context_data,
amount => length(l_var_xml_context),
offset => 1,
buffer => l_var_xml_context
l_xml_context := XMLTYPE(l_error_context_data);
-- validate against XML schema
--l_xml_context.schemavalidate();
l_ret := l_xml_context.isschemavalid('"http://ibtco.com/common/exception/context"');
IF l_ret = 1 then
dbms_output.put_line('Data is valid:' || l_ret );
ELSE
dbms_output.put_line('Data is invalid:' || l_ret);
END IF;
END;
/
problem was with the parameter you have passed as schema url.
here is the modified code.
problem was in this line.
l_xml_context.isschemavalid('"http://ibtco.com/common/exception/context"');
you have to pass the url as just a string without the double quotest (").
now it returns 1.
SQL> DECLARE
2 l_var_xml_context VARCHAR2(4000);
3 l_xml_context SYS.XMLTYPE;
4 l_ret NUMBER;
5 BEGIN
6 l_var_xml_context := '<?xml version="1.0" encoding="UTF-8"?>
7 <ExceptionContext xmlns="http://ibtco.com/common/exception/context" xmlns:xsi="http://www.w3.o
rg/2001/XMLSchema-instance" xsi:schemaLocation="http://ibtco.com/common/exception/context
8 http://ibtco.com/common/exception/context">
9 <Property Name="Name1" Type="boolean">true</Property>
10 <Property Name="Name2" Type="string">String</Property>
11 </ExceptionContext>';
12 l_xml_context := XMLTYPE(l_var_xml_context);
13
14 l_ret := l_xml_context.isschemavalid('http://ibtco.com/common/exception/context');
15 IF l_ret = 1 then
16 dbms_output.put_line('Data is valid:' || l_ret );
17 ELSE
18 dbms_output.put_line('Data is invalid:' || l_ret);
19 END IF;
20 END;
21 /
Data is valid:1
Similar Messages
-
Get XML Document Data step always returns NULL
Hi All,
I was hoping someone might be able to help with this.
I'm writing a holiday script, it uses XML to check whether the date is a holiday or halfday. XML below
<?xml version="1.0" encoding="ISO-8859-1"?>
<Holidays>
<Holiday Date="1/1/2012">Holiday</Holiday>
<Holiday Date="3/1/2012">Halfday</Holiday>
<Holiday Date="6/1/2012">Holiday</Holiday>
<Holiday Date="5/4/2012">Halfday</Holiday>
<Holiday Date="6/4/2012">Holiday</Holiday>
<Holiday Date="8/4/2012">Holiday</Holiday>
<Holiday Date="9/4/2012">Holiday</Holiday>
<Holiday Date="30/4/2012">Halfday</Holiday>
<Holiday Date="1/5/2012">Holiday</Holiday>
<Holiday Date="17/5/2012">Holiday</Holiday>
<Holiday Date="27/5/2012">Holiday</Holiday>
<Holiday Date="6/6/2012">Holiday</Holiday>
<Holiday Date="23/6/2012">Holiday</Holiday>
<Holiday Date="6/4/2012">Holiday</Holiday>
<Holiday Date="3/11/2012">Halfday</Holiday>
<Holiday Date="25/12/2012">Holiday</Holiday>
<Holiday Date="26/12/2012">Holiday</Holiday>
<Holiday Date="19/10/2012">Halfday</Holiday>
</Holidays>
However when I debug the script the result of the Get XML Document step always returns null.
Xpath work great in notepad++
My code is attached, anyone with any pointers?
Regards,
AndyYour XPATH of:
"/Holidays/Holiday[@Date='+DateString+']"
Needs to be:
"/Holidays/Holiday[@Date='"+DateString+"']"
Good luck and happy scripting!
Anthony Holloway
Please use the star ratings to help drive great content to the top of searches. -
UCCX XPath on Get XML Document Data Step always returns null
Hello,
Can someone tell whats wrong with my XPath, because it always returns null. I have tried different variations and nothing. I'm using UCCX 7.0
XML
<?xml version="1.0" encoding="utf-8" ?>
<GetManagersResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.labdomain.com/">
<ClaimManagersList>
<X_CLAIM_MANAGER>
<ClaimManagerUserName>test</ClaimManagerUserName>
</X_CLAIM_MANAGER>
</ClaimManagersList>
</GetManagersResult>
XPATH
"/descendant::GetManagersResult/child::ClaimManagersList/child::X_CLAIM_MANAGER/child::ClaimManagerUserName"
During debug, this is the value of the xml document when it reaches the Get XML Document Data step:
TEXT[<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<GetManagersResult xmlns=\"http://www.labdomain.com/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <ClaimManagersList>\r\n <X_CLAIM_MANAGER>\r\n <ClaimManagerUserName>test</ClaimManagerUserName>\r\n </X_CLAIM_MANAGER>\r\n </ClaimManagersList>\r\n</GetManagersResult>]It's your XML namespace in the root element.
First off, I have never seen the CRS Editor play nice when XML namespaces are involved.
Secondly, with your namespace in place, not even a generic xpath expression tester can find your data. See attachements.
I think that if you find a way to either: not send, or remove the namespace from your document, your xpath expression will work.
With Namespaces
Without Namespaces -
XML validation in sender file adapter
Hi
I am using FCC on the sender file adapter ....i need to make sure that one of the fields should always be integer else the sender adapter should give error
Can i use xml validation with FCC on the sender file adapter?Hi Hema,
As per understanding you need to check one or few fields value is integer or not.
You can achieve in 2 ways :
Case1:Using inbuilt xml validation options.
For 7.11 and below
1)In ESR/Message type/Export the xsd to local machine.
2)Insert the xsd file in the below loc
/usr/sap/<sid>/DVEBMGS00/j2ee/cluster/server0/validation/schema/
<guid>/<namespace1>/<service_interface_name>/<namespace2>
<sid>: System ID of the server instance.
<guid>: The GUID of the SWCV.
<namespace1> : The namespace within which the service interface is defined.
<service_interface_name> : The name of the service interface.
<namespace2>
: The namespace of the Message Type used by the service interface. In many
instances, namespace1 and namespace2 are the same.
Italic path folders need to create by you.
For 7.3 and above
Michal's PI tips: XML validation - changes in 7.3
Case 2 :Handling using simple UDF.
Input-->UDF-->Output
try {
Integer.parseInt(input);
return input ;
catch(NumberFormatException e) {
throw new StreamTransformationException( "Input field value for xyz field "+input+"is not in integer format.Plz correct it");
Regards
Venkat -
XML Validation with XSD in java mapping
Hi experts,
I have created an interface to send differents messages between bussines system, the bussiness system receiver is put in the message, to get this value I have a configuration file indicating the path of this field for each message type. In a java mapping I transform the message sent in this structure:
<document>
<message>HERE THE MESSAGE AS STRING</message>
<parameters>
<sender>HERE SENDER BUSSINESS SYSTEM</sender>
<receiver>HERE RECEIVER BUSSINESS SYSTEM</receiver>
</parameters>
</document>
the messaging interface works fine, but now I have to validate the XML vs XSD. I need doing in a java mapping because the messaging interface send the message and a email to sender in error case.
To do this validation I have implemented two java mappings that works fine in my local, the first way is with class Validator of java 5, but my system PI 7.1 return an error with this class. The second way is with SAX parse:
String schema = "XXXXXxsd";
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware(true);
docBuilderFactory.setValidating(true);
docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage","http://www.w3.org/2001/XMLSchema");
InputStream is = this.getClass().getClassLoader().getResourceAsStream(schema);
docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource",is);
in my local works fine but in PI always return OK never fail.
For this moment the schema is hardcoded to do proofs, in the future will be loaded from my configuration file.
Any idea?
Thanks in advance
Josehi Jose,
PI 7.1 has a built in feature available called XML vaidations ..
your source xml can be validated against a XSD placed at a specific location on the PI server..
validation can be performed at adapter/integration engine
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d06dff94-9913-2b10-6f82-9717d9f83df1?quicklink=index&overridelayout=true -
Hi experts,
I get the following error message in SXMB_MONI while processing a message through a WS sender adapter:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Error Message -->
<n0:Fault xmlns:n0="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>n0:Server</faultcode>
<faultstring xml:lang="en">SRT: Failure in SOAP processing occurred</faultstring>
<detail>
<ns:SystemFault xmlns:ns="http://www.sap.com/webas/710/soap/runtime/abap/fault/system/">
<Host>Integration Server Entry</Host>
<Component>COREMSG</Component>
<ChainedException>
<Exception_Name>CX_XMS_XI_SYS_ERR</Exception_Name>
<Exception_Text>System error</Exception_Text>
</ChainedException>
<ChainedException>
<Exception_Name>CX_XMS_SYSERR_VALIDATION</Exception_Name>
<Exception_Text>System error occurred during XML validation</Exception_Text>
</ChainedException>
</ns:SystemFault>
</detail>
</n0:Fault>
This is strange, because I didn't configure any XML validation. I didn't configure that explicitly.
However, I noticed that the step "XML Validation Inbound Channel Request ( CENTRAL )" is executed every time I send messages to PI. Normally this is successful, so the message flow is not interrupted. But even in the successful case the xml header is always cut off (so the line "<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>" in the beginning). I checked other messages with different adapters, and this step is never executed.
I would like to know whether this step can be switched off somewhere or whether it is performed by default. Does anybody know more about this topic?
Best regards,
JörgHi Hema,
As per understanding you need to check one or few fields value is integer or not.
You can achieve in 2 ways :
Case1:Using inbuilt xml validation options.
For 7.11 and below
1)In ESR/Message type/Export the xsd to local machine.
2)Insert the xsd file in the below loc
/usr/sap/<sid>/DVEBMGS00/j2ee/cluster/server0/validation/schema/
<guid>/<namespace1>/<service_interface_name>/<namespace2>
<sid>: System ID of the server instance.
<guid>: The GUID of the SWCV.
<namespace1> : The namespace within which the service interface is defined.
<service_interface_name> : The name of the service interface.
<namespace2>
: The namespace of the Message Type used by the service interface. In many
instances, namespace1 and namespace2 are the same.
Italic path folders need to create by you.
For 7.3 and above
Michal's PI tips: XML validation - changes in 7.3
Case 2 :Handling using simple UDF.
Input-->UDF-->Output
try {
Integer.parseInt(input);
return input ;
catch(NumberFormatException e) {
throw new StreamTransformationException( "Input field value for xyz field "+input+"is not in integer format.Plz correct it");
Regards
Venkat -
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 -
Request.getParameter() always returns null
I have a html file and am trying to retrieve the values from a formin my servlet.
here is the html code:
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<h1><b>Add DVD</b></h1>
</head>
<body>
<form action="add_dvd.do" method="POST">
Title:<input type="text" name="title" />
Year:<input type="text" name="year" />
Genre: <select name='gselected'>
<option value='Sci-Fi'>Sci-Fi</option>
</select>
or enter new genre:<input type="text" name='gentered' value="" />
<input type="submit" value="Add DVD" />
</form>
</body>
</html>
and here is the servlet code:
public class AddDVDServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// System.out.println("in AddDVDServlet post method");
List errorMsgs = new LinkedList();
//retrieve form parameters
try{
String title = request.getParameter("title").trim();
String year = request.getParameter("year").trim();
*String gentered = request.getParameter("gentered");
String gselected = request.getParameter("gselected");
String genre="";
if("".equals(gentered))
genre = gselected;
else
genre = gentered;
// System.out.println("parameter retrieved");
if(!year.matches("\\d\\d\\d\\d"))
// System.out.println("year not 4 digit long");
errorMsgs.add("Year must be four digit long");
if("".equals(title))
// System.out.println("title not entered");
errorMsgs.add("Please enter the title of the dvd");
if("".equals(genre))
// System.out.println("genre not valid");zdf
errorMsgs.add("Enter genre.");
if(! errorMsgs.isEmpty())
//System.out.println("errors in entry ");
request.setAttribute("errors",errorMsgs);
// System.out.println("error attribute set in request");
RequestDispatcher rd = request.getRequestDispatcher("error.view");
rd.forward(request, response);
return;
//create DVDItem instance
DVDItem dvd = new DVDItem(title,year,genre);
request.setAttribute("dvdItem",dvd);
RequestDispatcher rd = request.getRequestDispatcher("success.view");
rd.forward(request, response);
catch(Exception e){
errorMsgs.add(e.getMessage());
request.setAttribute("errors",errorMsgs);
RequestDispatcher rd = request.getRequestDispatcher("error.view");
rd.forward(request, response);
e.printStackTrace();
System.out.println("exception:"+e);
why does getParameter always return null??? whats wrong?I don't know. However, I suspect that because you have a tag with the same name as 'title', its causing a name conflict. Chnage the name to something else. If it works, then that's the likely explaination.
-
Global Temp Table, always return zero records
I call the procedure which uses glbal temp Table, after executing the Proc which populates the Global temp table, i then run select query retrieve the result, but it alway return zero record. I am using transaction in order to avoid deletion of records in global temp table.
whereas if i do the same thing in SQL navigator, it works
Cn.ConnectionString = Constr
Cn.Open()
If FGC Is Nothing Then
Multiple = True
'Search by desc
'packaging.pkg_msds.processavfg(null, ActiveInActive, BrandCode, Desc, Itemtype)
SQL = "BEGIN packaging.pkg_msds.processavfg(null,'" & _
ActiveInActive & "','" & _
BrandCode & "','" & _
Desc & "','" & _
Itemtype & "'); end;"
'Here it will return multiple FGC
'need to combine them
Else
'search by FGC
SQL = "BEGIN packaging.pkg_msds.processavfg('" & FGC & "','" & _
ActiveInActive & "','" & _
BrandCode & "',null,null); end;"
'will alway return one FGC
End If
' SQL = " DECLARE BEGIN rguo.pkg_msds.processAvedaFG('" & FGC & "'); end;"
Stepp = 1
Cmd.Connection = Cn
Cmd.CommandType = Data.CommandType.Text
Cmd.CommandText = SQL
Dim Trans As System.Data.OracleClient.OracleTransaction
Trans = Cn.BeginTransaction()
Cmd.Transaction = Trans
Dim Cnt As Integer
Cnt = Cmd.ExecuteNonQuery
'SQL = "SELECT rguo.pkg_msds.getPDSFGMass FROM dual"
SQL = "select * from packaging.aveda_mass_XML"
Cmd.CommandType = Data.CommandType.Text
Cmd.CommandText = SQL
Adp.SelectCommand = Cmd
Stepp = 2
Adp.Fill(Ds)
If Ds.Tables(0).Rows.Count = 0 Then
blError = True
BlComposeXml = True
Throw New Exception("No Record found for FGC(Finished Good Code=)" & FGC)
End If
'First Row, First Column contains Data as XML
Stepp = 0
Trans.Commit()Hi,
This forum is for Oracle's Data Provider and you're using Microsoft's, but I was curious so I went ahead and tried it. It works fine for me. Here's the complete code I used, could you point out what are you doing differently?
Cheers,
Greg
create global temporary table abc_tab(col1 varchar2(10));
create or replace procedure ins_abc_tab(v1 varchar2) as
begin
insert into abc_tab values(v1);
end;
using System;
using System.Data;
using System.Data.OracleClient;
class Program
static void Main(string[] args)
OracleConnection con = new OracleConnection("data source=orcl;user id=scott;password=tiger");
con.Open();
OracleTransaction txn = con.BeginTransaction();
OracleCommand cmd = new OracleCommand("begin ins_abc_tab('foo');end;", con);
cmd.Transaction = txn;
cmd.ExecuteNonQuery();
cmd.CommandText = "select * from abc_tab";
OracleDataAdapter da = new OracleDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
Console.WriteLine("rows found: {0}", ds.Tables[0].Rows.Count);
// commit, cleanup, etc ommitted for clarity
} -
XML Validation in PI 7.1 - Restart and skip validation possible, but how?
Hello all,
I read about schema validation in PI 7.1 and did a few tests on my own, but could not restart and skip validation for invalid payloaded messages. The documents say it is possible.
Anyone know how? Thanks.
BTW, I really think putting the schemas in server file system will cause a lot of authorization trouble in enterprises. No one gives access to the server filesystem and I don't think they will also like to open the required subdirectories for share. Asking the basis team to create the folder structures and maintaining schemas would be another pain. Don't you also think that SAP could find a better approach, like automatically uploading the schemas to the filesystem, or validating them from repository directly if possible?
Kind regards,
GökhanHi Gökhan,
I am facing the same issue.
I set up outbound xml validation in receiver agreement and tested it with valid and invalid messages.
The validation works fine.
But in case of validation error I tried to restart with skipping the validation. But this wasn't possible.
I am always facing the same valdiation error.
I already tried all different tools I know (sxi_monitor, message monitoring in rwb and in nwa)
I am working on PI 7.11 SP6
Did you find a solution for skipping the validation for a single message out of the monitoring?
I know that there is the possibility of deactivate the validation in receiver agreement but thid doesn't meet the requirement of skip the validation only for a single message.
Maybe anyone else faced and solved this issue already.
Thanks in advance
Jochen -
XML Validation - How to raise an alert
Hi PI Experts,
I enabled XML validation at "Validtion by Adapetr Engine". Its working fine. But how to integrate XML validation error with Alert Monitoring. Please advise.
Here below the error from Audit log:
2010-03-18 18:33:13 Information The application tries to send an XI message asynchronously using connection File_http://sap.com/xi/XI/System.
2010-03-18 18:33:13 Information Backward validation is enabled
2010-03-18 18:33:13 Error Unable to validate the message with message ID b01d356e-1801-4b93-29fb-9ed84b25c6a3
2010-03-18 18:33:13 Error Returning to application. Exception: com.sap.engine.interfaces.messaging.api.exception.MessageFormatException: cvc-enumeration-valid: Value '11' is not facet-valid with respect to enumeration '[1, 2, 3, 4, 5, 6, 7]'. It must be a value from the enumeration. at line 15, column 34
2010-03-18 18:33:13 Error MP: exception caught with cause com.sap.engine.interfaces.messaging.api.exception.MessageFormatException: cvc-enumeration-valid: Value '11' is not facet-valid with respect to enumeration '[1, 2, 3, 4, 5, 6, 7]'. It must be a value from the enumeration. at line 15, column 34
2010-03-18 18:33:13 Error File processing failed with com.sap.engine.interfaces.messaging.api.exception.MessageFormatException: cvc-enumeration-valid: Value '11' is not facet-valid with respect to enumeration '[1, 2, 3, 4, 5, 6, 7]'. It must be a value from the enumeration. at line 15, column 34
Thanks...
Ravi KanakamHi Ravi,
Are you getting other adapter engine alerts? Or only you are not getting xml validation ones? Also take a look at this:
/people/michal.krawczyk2/blog/2005/09/09/xi-alerts--troubleshooting-guide
Regards,
---Satish -
Since there is no XML validation currently in the Flex/Flash framework, I've decided to start a class that parses a string in an effort to validate the markup, returning whether the XML is valid. I have a need for it in my non-server based application, and have read in numerous places where there is desire for it as well. I have built the class far enough to get the ball rollin', but figure it should be :
A) available to the community
B) able to be improved upon by the community
If you improve upon the code, please post your work here so everyone can benefit.
Here is the source code :
XML Validator : v0.2 - last edit by Justin Myers | J2 CREATIVE MEDIA DESIGN
NOTES:
Parser is a bit weak and needs work.
Still need to :
- Make sure tags are ended properly
- Make sure there is space between tag name and attribute
Parser currently handles :
- Making sure there is no space between tags (with exception to white space)
- Making sure that attributes open and close properly
- Making sure there is proper space after an attribute or that it is immediately followed with the tag closing
package community.classes.parsers
public class XMLValidator
public function XMLValidator()
public static function validate(str:String , ignoreWhiteSpace:Boolean = true):Boolean
// validation defaults to true (innocent til proven guilty)
var valid:Boolean = true;
// minimum char length to be valid XML
if (str.length < 4)
valid = false;
var withinTag:Boolean;
var withinAttribute:Boolean;
var tags:Array = [];
var tag:String;
for (var i:uint = 0 ; i < str.length ; i++)
var char:String = str.charAt(i);
// if we are closing a tag
if (char == ">")
// invalid if we never opened a tag, or if we never closed the last attribute
if (!withinTag || withinAttribute)
valid = false;
break;
else
withinTag = false;
tags.push(tag);
// invalid if last character is not a closing tag
else if (i == str.length - 1)
valid = false;
break;
// if we are entering a tag
else if (char == "<")
// invalid if we haven't closed the last tag
if (withinTag)
valid = false;
break;
else
withinTag = true;
tag = "";
// all other characters
else
if ((char != " " || char != "\n") || ((char == " " || char == "\n") && !ignoreWhiteSpace) )
// invalid if there are any characters between tags
if (!withinTag)
valid = false;
break;
else
if (char == "\"")
// entering attribute
if (!withinAttribute)
// invalid if = does not preclude ", or there is space before =
if (str.charAt(i-1) != "=" || str.charAt(i-2) == " ")
valid = false;
break;
else
withinAttribute = true;
// exiting attribute
961190 wrote:
so whats the best way to store Rules?
How to get the data validated with those rules given the source data is in a xml file
The "integrity rules"?
Since they have to be ececutable code I'd suggest Java classes...
How to get the data validated with those rules given the source data is in a xml file
as @hsc71 wrote, that each XML element select the rules this particular element should pass and run each rule with the current element as parameter.
This meight be easiser in the Rules have a common interface like
interface Rule{
public boolean isPassedBy(XmlElement theCurrentElement, XmlElement theRootElement);
You could use the ServiceRegistry class from the JVM to fetch the known rules, so that you can add new ones with minimum effort.
bye
TPD -
Call thirty party java web service but always return null
hi
I call a java web service in my application visual studio 2008 c#, but always return NULL.
I used Tool Fiddler to monitor the traffic between my client and the web service server, it showed the return is not Null.
Here is my code, please see if anything I do wrong.
namespace CanOfficer_THQ_vs_IHQ.TestWebReferenceAppointment {
using System.Diagnostics;
using System.Web.Services;
using System.ComponentModel;
using System.Web.Services.Protocols;
using System;
using System.Xml.Serialization;
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="AppointmentServiceSoapBinding", Namespace="http://service.ips.salvationarmy.org/")]
public partial class AppointmentService : Microsoft.Web.Services3.WebServicesClientProtocol {
private System.Threading.SendOrPostCallback deleteAppOperationCompleted;
private System.Threading.SendOrPostCallback importAppOperationCompleted;
private System.Threading.SendOrPostCallback editAppOperationCompleted;
private bool useDefaultCredentialsSetExplicitly;
/// <remarks/>
public AppointmentService() {
this.Url = global::CanOfficer_THQ_vs_IHQ.Properties.Settings.Default.CanOfficer_THQ_vs_IHQ_TestWebReferenceAppointment_AppointmentService;
if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
this.UseDefaultCredentials = true;
this.useDefaultCredentialsSetExplicitly = false;
else {
this.useDefaultCredentialsSetExplicitly = true;
public new string Url {
get {
return base.Url;
set {
if ((((this.IsLocalFileSystemWebService(base.Url) == true)
&& (this.useDefaultCredentialsSetExplicitly == false))
&& (this.IsLocalFileSystemWebService(value) == false))) {
base.UseDefaultCredentials = false;
base.Url = value;
public new bool UseDefaultCredentials {
get {
return base.UseDefaultCredentials;
set {
base.UseDefaultCredentials = value;
this.useDefaultCredentialsSetExplicitly = true;
/// <remarks/>
public event deleteAppCompletedEventHandler deleteAppCompleted;
/// <remarks/>
public event importAppCompletedEventHandler importAppCompleted;
/// <remarks/>
public event editAppCompletedEventHandler editAppCompleted;
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(
RequestNamespace="http://service.ips.salvationarmy.org/",
ResponseNamespace="http://service.ips.salvationarmy.org/",
Use=System.Web.Services.Description.SoapBindingUse.Encoded,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("return", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string deleteApp([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] int id) {
object[] results = this.Invoke("deleteApp", new object[] {
id});
return ((string)(results[0]));
/// <remarks/>
public void deleteAppAsync(int id) {
this.deleteAppAsync(id, null);
/// <remarks/>
public void deleteAppAsync(int id, object userState) {
if ((this.deleteAppOperationCompleted == null)) {
this.deleteAppOperationCompleted = new System.Threading.SendOrPostCallback(this.OndeleteAppOperationCompleted);
this.InvokeAsync("deleteApp", new object[] {
id}, this.deleteAppOperationCompleted, userState);
private void OndeleteAppOperationCompleted(object arg) {
if ((this.deleteAppCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.deleteAppCompleted(this, new deleteAppCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(
RequestNamespace="http://service.ips.salvationarmy.org/",
ResponseNamespace="http://service.ips.salvationarmy.org/",
Use=System.Web.Services.Description.SoapBindingUse.Encoded,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("return", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string importApp(
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] int person,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string name,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string territory,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string location,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] bool primary,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] Nullable<System.DateTime> start,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] Nullable<System.DateTime> end,
[System.Xml.Serialization.XmlElementAttribute("categories", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string[] categories) {
object[] results = this.Invoke("importApp", new object[] {
person,
name,
territory,
location,
primary,
start,
end,
categories});
return ((string)(results[0]));
/// <remarks/>
public void importAppAsync(int person, string name, string territory, string location, bool primary, Nullable<System.DateTime> start, Nullable<System.DateTime> end, string[] categories) {
this.importAppAsync(person, name, territory, location, primary, start, end, categories, null);
/// <remarks/>
public void importAppAsync(int person, string name, string territory, string location, bool primary, Nullable<System.DateTime> start, Nullable<System.DateTime> end, string[] categories, object userState) {
if ((this.importAppOperationCompleted == null)) {
this.importAppOperationCompleted = new System.Threading.SendOrPostCallback(this.OnimportAppOperationCompleted);
this.InvokeAsync("importApp", new object[] {
person,
name,
territory,
location,
primary,
start,
end,
categories}, this.importAppOperationCompleted, userState);
private void OnimportAppOperationCompleted(object arg) {
if ((this.importAppCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.importAppCompleted(this, new importAppCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(
RequestNamespace="http://service.ips.salvationarmy.org/",
ResponseNamespace="http://service.ips.salvationarmy.org/",
Use=System.Web.Services.Description.SoapBindingUse.Encoded,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("return", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string editApp(
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] int id,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string name,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string territory,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string location,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] bool primary,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] Nullable<System.DateTime> start,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] Nullable<System.DateTime> end,
[System.Xml.Serialization.XmlElementAttribute("categories", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string[] categories) {
object[] results = this.Invoke("editApp", new object[] {
id,
name,
territory,
location,
primary,
start,
end,
categories});
return ((string)(results[0]));
/// <remarks/>
public void editAppAsync(int id, string name, string territory, string location, bool primary, Nullable<System.DateTime> start, Nullable<System.DateTime> end, string[] categories) {
this.editAppAsync(id, name, territory, location, primary, start, end, categories, null);
/// <remarks/>
public void editAppAsync(int id, string name, string territory, string location, bool primary, Nullable<System.DateTime> start, Nullable<System.DateTime> end, string[] categories, object userState) {
if ((this.editAppOperationCompleted == null)) {
this.editAppOperationCompleted = new System.Threading.SendOrPostCallback(this.OneditAppOperationCompleted);
this.InvokeAsync("editApp", new object[] {
id,
name,
territory,
location,
primary,
start,
end,
categories}, this.editAppOperationCompleted, userState);
private void OneditAppOperationCompleted(object arg) {
if ((this.editAppCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.editAppCompleted(this, new editAppCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
/// <remarks/>
public new void CancelAsync(object userState) {
base.CancelAsync(userState);
private bool IsLocalFileSystemWebService(string url) {
if (((url == null)
|| (url == string.Empty))) {
return false;
System.Uri wsUri = new System.Uri(url);
if (((wsUri.Port >= 1024)
&& (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
return true;
return false;
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
public delegate void deleteAppCompletedEventHandler(object sender, deleteAppCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class deleteAppCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal deleteAppCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
/// <remarks/>
public string Result {
get {
this.RaiseExceptionIfNecessary();
return ((string)(this.results[0]));
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
public delegate void importAppCompletedEventHandler(object sender, importAppCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class importAppCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal importAppCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
/// <remarks/>
public string Result {
get {
this.RaiseExceptionIfNecessary();
return ((string)(this.results[0]));
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
public delegate void editAppCompletedEventHandler(object sender, editAppCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class editAppCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal editAppCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
/// <remarks/>
public string Result {
get {
this.RaiseExceptionIfNecessary();
return ((string)(this.results[0]));Hi;
I used Fiddler to monitor the process, and it showed the request sent thru web service worked and returned a value, but in my .Net application the return captured as NULL. Could you please look into the code above and the result from Filddler and see if
you can help.
thank you.
REQUEST:
POST https://159.253.140.178/services/AppointmentService HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.4252)
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Host: 159.253.140.178
Content-Length: 1589
Expect: 100-continue
Connection: Keep-Alive
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://service.ips.salvationarmy.org/" xmlns:types="http://service.ips.salvationarmy.org/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<soap:Header>
<wsse:Security mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>
[email protected]
</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
tpi4IPSws!
</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<tns:importApp>
<person xsi:type="xsd:int">
169275
</person>
<name xsi:type="xsd:string">
Corps Officer (Cahul-Russia) Test12
</name>
<territory xsi:type="xsd:string">
CAN
</territory>
<location xsi:type="xsd:string">
TEST LOCATION 12
</location>
<primary xsi:type="xsd:boolean">
true
</primary>
<start xsi:type="xsd:dateTime">
2013-05-30T00:00:00
</start>
<end xsi:type="xsd:dateTime">
2014-06-04T00:00:00
</end>
<categories href="#id1" />
</tns:importApp>
<soapenc:Array id="id1" soapenc:arrayType="xsd:string[1]">
<Item>
vpsCat1
</Item>
</soapenc:Array>
</soap:Body>
</soap:Envelope>
RESPONSE:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=UTF-8
Content-Length: 232
Date: Fri, 05 Sep 2014 19:45:22 GMT
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:importAppResponse xmlns:ns2="http://service.ips.salvationarmy.org/">
<return>
OK_572463
</return>
</ns2:importAppResponse>
</soap:Body>
</soap:Envelope> -
Hi all,
I am parsing an XML file passed in at the cmd line and using this method to return a boolean if depending if the validation was ok....I have successfully validated against the particular file that I am passing in against a valid XSD and it works fine. But when I do this here it gets caught as an error straight away.
Can anyone see any obvious mistakes with this code or have any suggestions?
public boolean validateXML() {
try {
boolean validate = true;
parser.setFeature("http://xml.org/sax/features/validation", validate);
//CustomerErrorHandler extends SAX ErrorHandler
CustomErrorHandler handler = new CustomErrorHandler();
//Install/Enable the parser to handle parsing errors
parser.setErrorHandler(handler);
parser.parse(args[0]);
System.out.println("YOU ARE IN THE XMLVALIDATOR CODE NOW!!!!");
validXML = true;
catch (Exception ex) {
System.out.println("An error has been caught, following validation");
validXML = false;
return validXML;
}Hi thanks for the response,
I did not quite get what you meant from youre last post to this question. From what I understand from the lines you gave the following 3 lines need to be added to the class:
parser.setFeature("http://apache.org/xml/features/validation/schema", validate);parser.setFeature
("http://apache.org/xml/features/validation/schema-full-checking", validate);parser.setProperty
("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", schemaUrl);Then what I understood was to declare a String variable (schemaUrl) which is the actual location of the XML document? So in my case this would be "c://winnt/desktop/note.xml....
I was not clear on when you said:
XML document url (argv[0]) and schema document url should be file url:
file://c:/schema/xmldoc.xml
Thanks again, -
XML validation using javax.xml.validation
Hello,
I am trying to validate some xml against my xsd.
Here is my xml:
<host>
<status>Unknown</status>
</host>Here is my xsd:
<?xml version="1.0"?>
<xsd:schema targetNamespace="blah"
xmlns:tns="blah"
xmlns:xsd="blah">
<xsd:simpleType name="Status">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Unknown"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="host">
<xsd:complexType>
<xsd:all>
<xsd:element name="status" type="tns:Status"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:schema>My test code is:
try
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = parser.parse(new File("test.xml"));
// Create a SchemaFactory capable of understanding WXS schemas.
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
// Load a WXS schema, represented by a Schema instance.
StreamSource schemaFile = new StreamSource(new File("schema.xsd"));
Schema schema = factory.newSchema(schemaFile);
// Create a Validator object, which can be used to validate the document
Validator validator = schema.newValidator();
// Validate the DOM tree.
validator.validate(new DOMSource(document));
catch(Exception e)
fail("XML validation failed: " + e.getMessage());
}I get the following error:
ERROR: 'cvc-elt.1: Cannot find the declaration of element 'host'.'
If i replace "type=tns:Status' in the "status" element with just "type=string", it works fine.
Does anyone have any idea what the problem is?
Thank you,
DavidTo daft_davy:
1. Your XSD document is invalid: the xmlns attribute of schema documents must always have the following value: "http://www.w3.org/2001/XMLSchema"
All other values will result in the following validation error:
org.xml.sax.SAXParseException: s4s-elt-schema-ns: The namespace of element 'schema' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'.
Your XSD should look like this:
<?xml version="1.0"?>
<xsd:schema targetNamespace="blah" xmlns:tns="blah" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="Status">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Unknown"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="host">
<xsd:complexType>
<xsd:all>
<xsd:element name="status" type="tns:Status"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:schema>2. Your XML document does not match the XSD schema (even if you use the one above) for the following reasons:
a) The root element of the XML document must be associated with the namespace defined by the targetNamespace attribute of the schema.
b) The "blah" namespace at the element <status> in the XML document has to be undeclared because there is no namespace declaration to this element in the schema document either. There are to ways to do this:
<host xmlns="blah">
<status xmlns="">Unknown</status>
</host>or:
<xxx:host xmlns:xxx="blah">
<status>Unknown</status>
</xxx:host>
To watertownjordan:
The namespace URI can be virtually any string, so you don't need to specify a valid URI to define a namespace.
Maybe you are looking for
-
Request for advice: TM/TC fails on one Macbook Pro, but not the other?
Dear All- looking for some advice. Background: I installed a 1TB TC about 3 months ago to improve the wireless connectivity around the home/small business and to act as 1 stop backup- primarily for 2 main Macbook Pro’s. Everything seems to work fine,
-
How to configure Java Plug-In in Mozilla 1.4 and Netscape 7 on Red Hat 9?
How to configure the java plug-in (Java 2 v1.4.2) to work on Mozilla 1.4 and Netscape 7 on Red Hat 9? Thanks in advance.
-
How to make awt modal dialog to NOT appear on top of existing windows
Hi, I am working on a program that displays awt modal dialog box when it needs some action from the user. My problem is that the modal dialog box cann't be top window as there is one VC++ window that needs to be always top window. Another requirement
-
we have developed an Enterprise Java Bean for OC4J (version 9.0.2.0.0) which is running on Win2000 OS without any bugs. when we deployed the same EAR file in OC4J (version 1.0.2.0.0) on linux OS.we r getting an error like this----> java.lang.Instanti
-
How to upddate Nvidia driver for my Windows in bootcamp?
Hi I just want to ask if just using the Nvidia driver that it suggest from the udpate tab in the control panel of Nvidia is the way I can update my driver, or is there a special way to update when you are using bootcamp?