Specifying an argument name in a web service operation

As mentioned earlier, when WSDL was created for our Course web service, the argument for the getCourse operation name was created as arg0. You can verify this by browsing to http://localhost:8080/CourseMgmtWSProject/courseService?xsd=1 and checking the getCourse type:

<xs:complexType name="getCourse"> 
     <xs:sequence> 
         <xs:element name="arg0" type="xs:int"/> 
     </xs:sequence> 
</xs:complexType> 

Thus, the client-side-generated code (by wsimport) in CourseManagementService.getCourse also names the argument as arg0. It would be nice to give a meaningful name to arguments. This could be done easily be adding the @WSParam annotation in our web service implementation class, CourseManagementService:

public Course getCourse(@WebParam(name="courseId") int courseId) {...} 

Restart Tomcat after this change and browse to the WSDL schema URL (http://localhost:8080/CourseMgmtWSProject/courseService?xsd=1) again. You should now see a proper argument name in the getCourse type:

<xs:complexType name="getCourse"> 
     <xs:sequence> 
         <xs:element name="courseId" type="xs:int"/> 
     </xs:sequence> 
</xs:complexType> 

Generate the client-side code again by using wsimport, and you will see that argument of the getCourse method is named courseId.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.137.75