2

My xml is like below:-

<?xml version="1.0"?>
<create xmlns:xsi="https://csu.service-now.com">
    <sys_id xsi:type="xsd:string">30b78e589d5d0a00eba30ec92748d7fa</sys_id>
<number xsi:type="xsd:string">INC0135185</number>
</create>

I wants to creating an xsd by which the validation will be successful. So basically that by that xsd first I have to create a schema in webmethods and validate xml against that xml.

what I tried so far is :

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="create">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="sys_id">
          <xs:complexType>
            <xs:simpleContent>
              <xs:extension base="xs:string">
                <xs:attribute ref="csu:type" xmlns:csu="https://csu.service-now.com"/>
              </xs:extension>
            </xs:simpleContent>
          </xs:complexType>
        </xs:element>
        <xs:element name="number">
          <xs:complexType>
            <xs:simpleContent>
              <xs:extension base="xs:string">
                <xs:attribute ref="csu:type" xmlns:csu="https://csu.service-now.com"/>
              </xs:extension>
            </xs:simpleContent>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

but its failing there to create schema in webmethods.Looks like this is not a valid xsd as per webmethod.i tried many but no luck.

Please help here.

Christian Strempfer
  • 7,291
  • 6
  • 50
  • 75
samash
  • 757
  • 2
  • 15
  • 32

1 Answers1

1

If you want to suffer then writing an XSD that webMethods is able to understand is the way to go.

Is there any reason why you have to make an XSD?

The easiest way to learn what is acceptable for webMethods is to create a web service and then copy paste the WSDL URL in the browser and observe how webMethods defines everything within the "<xsd:schema ..> ... </xsd:schema>" then try to apply the same structure to define your own custom XSD.

The following is off the top of my head:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema 
    targetNamespace="http://some.target.namespace/test" 
    xmlns:tns="http://some.target.namespace/test" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="ServiceRequest" type="tns:ServiceRequest"/>
    <xsd:complexType name="ServiceRequest">
        <xsd:sequence>
            <xsd:element name="Create" nillable="false" type="tns:Create"/>
        </xsd:sequence>
    </xsd:complexType>  
    <xsd:complexType name="Create">
        <xsd:sequence>
            <xsd:element name="sys_id" nillable="true" type="xsd:string"/>
            <xsd:element name="number" nillable="true" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>  
</xsd:schema>

Again, if you can, try to steer away from XSDs. WebMethods is extremely picky when it comes to XSDs.

If you use some kind of GUI software to generate an XSD then it's almost certain that the generated XSD won't be compatible in webMethods.

Often what I do, instead of importing an XSD within webMethods, is to read the XSD in notepad and manually reproduce the structure in webMethods by manually defining the documents and fields.

TchiYuan
  • 4,258
  • 5
  • 28
  • 35
  • because I need to validate the the incomming xml against schema.and by generating the xsd we can create the schema – samash Oct 29 '15 at 11:03