Getting object as return value of XML web service

nightowl

Member
Joined
Oct 31, 2006
Messages
9
Programming Experience
Beginner
Hello. I'm new to web services. I'm trying to test my web service. It both accepts and returns an XML attribute type, and I'm looking for the best way to test it by giving it data, and viewing the results.

I did the introductory 'Hello World' web service and it was easy to test because it simply returns test. But I'm returning an OBJECT and I'm clueless. Please enlighten me!

Here's the WebMethod:

<WebMethod()> _
Public Overridable Function EmployeeValidation(<System.Xml.Serialization.XmlElementAttribute("EmployeeValidation-Request", [Namespace]:="CATSIVRSchema.xsd")> ByVal employeeValidationRequest As EmployeeValidationREQ) As <System.Xml.Serialization.XmlElementAttribute("EmployeeValidation-Response", [Namespace]:="CATSIVRSchema.xsd")> EmployeeValidationRESP Implements ICATSIVRServicePort.EmployeeValidation

End Function

Here's the EmployeeValidation-Request entries from the XSD:

</xs:element>
<xs:element name="EmployeeValidation-Request" type="EmployeeValidation-REQ">
<!-- element that instantiates the request for EmployeeValidation -->
</xs:element>

<xs:complexType name="EmployeeValidation-REQ">
<!-- Complex Type that contains request information for EmployeeValidation -->
<xs:sequence>
<xs:element name="EmployeeValidation-DataIn" type="EmployeeValidation-DataIn" />
</xs:sequence>
</xs:complexType>

<xs:complexType name="EmployeeValidation-DataIn">
<!-- Complex Type that contains all information required for executing the CATS IMS Call EmployeeValidation -->
<xs:sequence>
<xs:element name="EmployeeValidation-TransactionCode" type="TransactionCode" />
<xs:element name="EmployeeValidation-AirlineCode" type="AirlineCode" />
<xs:element name="EmployeeValidation-EmployeeNumber" type="EmployeeNumber" />
<xs:element name="EmployeeValidation-PinNumber" type="PinNumber" />
<xs:element name="EmployeeValidation-ErrorCode" type="ErrorCode" />
<xs:element name="EmployeeValidation-UnixTimeStamp" type="UnixTimeStamp" />
</xs:sequence>
</xs:complexType>

ANY help would be appreciated, no matter how trivial!!
 
Debug your webservice from winform

no matter how trivial!!

You can debug your web service from a winform call into it (assuming net2.0 but net1.1 even easier)

1) Add a winform project to the same solution your webservice is in. Then right-click on the solution choose properties and select "Multiple Setup Projects"
Make sure the webservice is selected as one that starts then right click on winform project and choose "set as startup project" it should be bold now.

2) Then go to the webservice and right-click choose properties and select
"Start Options" and select "Don't open a page, wait for a request from an external application"

3)Then in web.config of the web service set the "compilation" to "debug=true"
Now you can call the webservice from the winform and actually debug step into the web service for debugging.

4) also others in this forum recommend using FIDDLER and YATT tracing tools (google them) and also the IE developer toolbar
 
Last edited:
XML Web service help

Thanks for your help, jhomminga. I did as you said, and my WinForm is set to start up first.

Now, in using that WinForm to call my service is also where I need help. I added a web reference to my service from the WinForm, and I need to send to it some XML structured in such a way that my WebService can receive it, and I can parse it.

I'm not sure where to start...
 
Try this

First set a variable to the type in the webservice that it expects to receive.

Then new up an object that points to your web service reference class name

Then call the method, just like you would if it were local, and get the result back.

Then inspect the result.

VB.NET:
Dim oSendParams As Localhost.YourClassName.EmployeeValidationREQ
With oSendParams
     .TransactionCode=""
     .AirlineCode=""
     .EmployeeNumber=""
     .PinNumber=""
     .ErrorCode=""
     .UnixTimeStamp=""
End With
 
Dim oService as Localhost.YourClassName
Dim oReturn as Object = oService.TheMethodName(oSendParams)
Debug.Print(oReturn.String)


Some other things to do use
  • WSDL.EXE to generate the class.
  • Add HTTP-GET to be able to call from URL
  • Copy the class local and use it without webservice for debugging
  • Share the types in a common library
 
Last edited:
XML Web service help

jhomminga - Thanks SO MUCH for your help! You pointed me in the right direction. Here's what I've got working now in my WinForm (with some help from my mentor, whom I haven't been able to get in contact with until recently):

In the WinForm:
VB.NET:
[SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] IVRServicesTestForm.localhost[/SIZE]
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=2] Form1[/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] myWebServicehost [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] localhost.CATSIVRServicePort[/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] btnEmployeeValidation_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] btnEmployeeValidation.Click[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myRequest [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] EmployeeValidationREQ[/SIZE]
[SIZE=2]myRequest.EmployeeValidationDataIn = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] EmployeeValidationDataIn[/SIZE]
[SIZE=2]myRequest.EmployeeValidationDataIn.EmployeeValidationAirlineCode = [/SIZE][SIZE=2][COLOR=#a31515]"USA"[/COLOR][/SIZE]
[SIZE=2]myRequest.EmployeeValidationDataIn.EmployeeValidationEmployeeNumber = [/SIZE][SIZE=2][COLOR=#a31515]"19108"[/COLOR][/SIZE]
[SIZE=2]myRequest.EmployeeValidationDataIn.EmployeeValidationPinNumber = [/SIZE][SIZE=2][COLOR=#a31515]"2902"[/COLOR][/SIZE]
[SIZE=2]myRequest.EmployeeValidationDataIn.EmployeeValidationTransactionCode = [/SIZE][SIZE=2][COLOR=#a31515]"ucv002v "[/COLOR][/SIZE]
[SIZE=2]myRequest.EmployeeValidationDataIn.EmployeeValidationErrorCode = [/SIZE][SIZE=2][COLOR=#a31515]" "[/COLOR][/SIZE]
[SIZE=2]myRequest.EmployeeValidationDataIn.EmployeeValidationUnixTimeStamp = [/SIZE][SIZE=2][COLOR=#a31515]" "[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myResponse [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] EmployeeValidationRESP[/SIZE]
[SIZE=2]myResponse = myWebServicehost.EmployeeValidation(myRequest)[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Form1_Load([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].Load[/SIZE]
[SIZE=2]myWebServicehost = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] localhost.CATSIVRServicePort[/SIZE]
[SIZE=2]myWebServicehost.Url = [/SIZE][SIZE=2][COLOR=#a31515]"http://localhost/IVRServices/CATSIVRService.asmx"[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE]

In the WebService:
VB.NET:
[SIZE=2]<System.Web.Services.WebMethodAttribute(), _[/SIZE]
[SIZE=2]System.Web.Services.Protocols.SoapDocumentMethodAttribute([/SIZE][SIZE=2][COLOR=#a31515]"localhost:employeeValidationIn"[/COLOR][/SIZE][SIZE=2], Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Bare, Binding:=[/SIZE][SIZE=2][COLOR=#a31515]"CATSIVRService"[/COLOR][/SIZE][SIZE=2])> _[/SIZE]
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Overridable[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Function[/COLOR][/SIZE][SIZE=2] EmployeeValidation(<System.Xml.Serialization.XmlElementAttribute([/SIZE][SIZE=2][COLOR=#a31515]"EmployeeValidation-Request"[/COLOR][/SIZE][SIZE=2], [Namespace]:=[/SIZE][SIZE=2][COLOR=#a31515]"CATSIVRSchema.xsd"[/COLOR][/SIZE][SIZE=2])> [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] employeeValidationRequest [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] EmployeeValidationREQ) [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] <System.Xml.Serialization.XmlElementAttribute([/SIZE][SIZE=2][COLOR=#a31515]"EmployeeValidation-Response"[/COLOR][/SIZE][SIZE=2], [Namespace]:=[/SIZE][SIZE=2][COLOR=#a31515]"CATSIVRSchema.xsd"[/COLOR][/SIZE][SIZE=2])> EmployeeValidationRESP [/SIZE][SIZE=2][COLOR=#0000ff]Implements[/COLOR][/SIZE][SIZE=2] ICATSIVRServicePort.EmployeeValidation[/SIZE]
[SIZE=2][COLOR=#008000]' TODO Create Text to call IMS (mainframe database call...)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] strRequest [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] StringBuilder[/SIZE]
[SIZE=2]strRequest.Append(employeeValidationRequest.EmployeeValidationDataIn.EmployeeValidationTransactionCode)[/SIZE]
[SIZE=2]strRequest.Append(employeeValidationRequest.EmployeeValidationDataIn.EmployeeValidationAirlineCode)[/SIZE]
[SIZE=2]strRequest.Append(employeeValidationRequest.EmployeeValidationDataIn.EmployeeValidationEmployeeNumber)[/SIZE]
[SIZE=2]strRequest.Append(employeeValidationRequest.EmployeeValidationDataIn.EmployeeValidationPinNumber)[/SIZE]
[SIZE=2]strRequest.Append(employeeValidationRequest.EmployeeValidationDataIn.EmployeeValidationErrorCode)[/SIZE]
[SIZE=2]strRequest.Append(employeeValidationRequest.EmployeeValidationDataIn.EmployeeValidationUnixTimeStamp)[/SIZE]
[SIZE=2][COLOR=#008000]'TODO Send 3270 Request using strRequest.ToString() (mainframe database call...)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]' TODO Create XML Response[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myResponse [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] EmployeeValidationRESP[/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataIn = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] EmployeeValidationDataIn[/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataOut = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] EmployeeValidationDataOut[/SIZE]
[SIZE=2][COLOR=#008000]' Build Response Header[/COLOR][/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataIn.EmployeeValidationAirlineCode = employeeValidationRequest.EmployeeValidationDataIn.EmployeeValidationAirlineCode[/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataIn.EmployeeValidationEmployeeNumber = employeeValidationRequest.EmployeeValidationDataIn.EmployeeValidationEmployeeNumber[/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataIn.EmployeeValidationPinNumber = employeeValidationRequest.EmployeeValidationDataIn.EmployeeValidationPinNumber[/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataIn.EmployeeValidationTransactionCode = employeeValidationRequest.EmployeeValidationDataIn.EmployeeValidationTransactionCode[/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataIn.EmployeeValidationErrorCode = 2[/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataIn.EmployeeValidationUnixTimeStamp = DateTime.Now.ToString[/SIZE]
[SIZE=2][COLOR=#008000]' Build Body[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] imsResponse [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#a31515]"UCV002V USA19108290202 DCAAB CAPRSVAVLP NN"[/COLOR][/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataOut.EmployeeValidationCrewBase = imsResponse.Substring(38, 3)[/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataOut.EmployeeValidationCrewEquipment = [/SIZE][SIZE=2][COLOR=#a31515]"AB "[/COLOR][/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataOut.EmployeeValidationCrewPosition = [/SIZE][SIZE=2][COLOR=#a31515]"CAP"[/COLOR][/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataOut.EmployeeValidationBlockHolderStatus = [/SIZE][SIZE=2][COLOR=#a31515]"RSV"[/COLOR][/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataOut.EmployeeValidationAvailabilityStatus = [/SIZE][SIZE=2][COLOR=#a31515]"AVL"[/COLOR][/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataOut.EmployeeValidationCrewPosition = [/SIZE][SIZE=2][COLOR=#a31515]"P"[/COLOR][/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataOut.EmployeeValidationVRSMenuMask = [/SIZE][SIZE=2][COLOR=#a31515]" "[/COLOR][/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataOut.EmployeeValidationLineMask = [/SIZE][SIZE=2][COLOR=#a31515]" "[/COLOR][/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataOut.EmployeeValidationMailWaiting = [/SIZE][SIZE=2][COLOR=#a31515]"N"[/COLOR][/SIZE]
[SIZE=2]myResponse.EmployeeValidationDataOut.EmployeeValidationSpecialMessageIndicator = [/SIZE][SIZE=2][COLOR=#a31515]"N"[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Return[/COLOR][/SIZE][SIZE=2] myResponse[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Function[/COLOR][/SIZE]

I am able to debug it as well. Thanks again for your help. I appreciate the references to FIDDLER, YATT, IE Developer Toolbar & WSDL.exe, not of which I had used before.
 
Back
Top