Hello All,
I am new to using NuSOAP, and have been making good
progress, but now I'm stuck.
I am access the webservice with a client app written
in CSharp. I have had sucess with simple functions
that pass strings, and return strings, but now need to
return complex data types.
I need to call a function which returns a list of
appointments in complex data form. I define the
following in the webservice:
$server->wsdl->addComplexType(
'Appointment',
'complexType',
'struct',
'all',
'',
array(
'first' =>
array('name'=>'first','type'=>'xsd:string'),
'last' =>
array('name'=>'last','type'=>'xsd:string'),
'modality' =>
array('name'=>'modality','type'=>'xsd:string'),
'procedure' =>
array('name'=>'procedure','type'=>'xsd:string')
)
);
$server->wsdl->addComplexType(
'AptArray',
'complexType',
'array',
'all',
'SOAP-ENC:Array',
array(array('ref'=>'SOAP-ENC:arrayType',
'wsdl:arrayType'=>'tns:Appointment'
)
)
);
$server->register('getAppointments',
array('city'=>'xsd:string'), // input
array('return'=>'tns:AptArray'), // output
$NAMESPACE, // namespace
$NAMESPACE.'#getAppointments', // soapaction
'rpc', // style
'encoded', // use
'Lists Appointments by city' //
documentation
);
---
I use the wsdl.exe command line program with .NET to
generate a webservice proxy in C#.
It creates:
/// <remarks/>
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="The_Worx_Group_Web_ServiceBinding",
Namespace="urn:theworxgroupwsdl")]
public class NVRAWebService :
System.Web.Services.Protocols.SoapHttpClientProtocol {
/// <remarks/>
public NVRAWebService() {
this.Url =
"http://dev.nvra.com/phpworx/webservice.php";
}
/// <remarks/>
[System.Web.Services.Protocols.SoapRpcMethodAttribute("urn:theworxgroupwsdl#getAppointments",
RequestNamespace="urn:theworxgroupwsdl",
ResponseNamespace="urn:theworxgroupwsdl")]
[return:
System.Xml.Serialization.SoapElementAttribute("return")]
public AptArray getAppointments(string city) {
object[] results =
this.Invoke("getAppointments", new object[] {
city});
return ((AptArray)(results[0]));
}
/// <remarks/>
public System.IAsyncResult
BegingetAppointments(string city, System.AsyncCallback
callback, object asyncState) {
return this.BeginInvoke("getAppointments", new
object[] {
city}, callback, asyncState);
}
/// <remarks/>
public AptArray
EndgetAppointments(System.IAsyncResult asyncResult) {
object[] results =
this.EndInvoke(asyncResult);
return ((AptArray)(results[0]));
}
}
/// <remarks/>
[System.Xml.Serialization.SoapTypeAttribute("AptArray",
"urn:theworxgroupwsdl")]
public class AptArray {
}
Now in my code, how do I interpret the return type?
For example:
try {
NVRAWebService ws = new NVRAWebService();
??????? = ws.getAppointments("mytown");
} catch (Exception ex) {
MessageBox.Show(ex.ToString());
}
What class/data type can I use to receive the results
of the call, and how do I iterate through the results?
Thanks,
-Frank
__________________________________
Do you Yahoo!?
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
|