Making input parameter compulsory in a webservice (using AXIS2)
I am using AXIS2 Framework for creating and accesing a webservice. Using Axis2 everything is fine for me. But i have a requirement that when i access thsi webserivce through soapui to test the webservice; in requesrt.xml it must show what are the optional parameters and compulsory parameters.
But at presen it showing like below:
<soapenv:Body>
<xsd:insert开发者_StackOverflow社区sStudent>
<!--Optional:-->
<xsd:studentId>?</xsd:employeeId>
<!--Optional:-->
<xsd:emailAddress>?</xsd:emailAddress>
</xsd:insertsStudent>
</soapenv:Body>
Inthe above sample soap request i want studentId as compulsory valu then how can i display it as compulsory in soap request.(like below)
<soapenv:Body>
<xsd:insertsStudent>
<!--compulsory:-->
<xsd:studentId>?</xsd:employeeId>
<!--Optional:-->
<xsd:emailAddress>?</xsd:emailAddress>
</xsd:insertsStudent>
</soapenv:Body>
In the request/response samples created by soapUI you get an <!--Optional:-->
comment above each field that is declared as optional in the corresponding XSD types definition of your WSDL file. If an element is mandatory soapUI displays nothing above it.
Your requirement is very strange. You have to make the element mandatory in your WSDL, not make soapUI display a <!--compulsory:-->
comment above an element which clearly is optional.
The above means that you have something similar to this in your WSDL:
<xsd:element name="insertsStudent">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="studentId" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="emailAddress" type="xsd:string" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
minOccurs="0" maxOccurs="1"
means optional;
minOccurs="1" maxOccurs="1"
means mandatory (compulsory).
If you change minOccurs
to 1 for studentId
you will get a mandatory field and soapUI will display this:
<soapenv:Body>
<xsd:insertsStudent>
<xsd:studentId>?</xsd:employeeId>
<!--Optional:-->
<xsd:emailAddress>?</xsd:emailAddress>
</xsd:insertsStudent>
</soapenv:Body>
Actually I am just doing coding part. I am not generating any wsdl file (Axis2 automatically displaying wsdl file in browser when u request webservice like http://localhost:8080/services/testwebservice?wsdl).
So can you tell me how can we change the behaviuor of generating wsdl file using axis2.
精彩评论