Krisztian Racz

Krisztian Racz

  • NA
  • 27
  • 756

XAMARIN Cross platform

Jun 2 2021 9:25 AM
Hi,
 
I'm new in Xamarin, and I'ld like to do a simple Hello World app. It communicate a NUSOAP webservice. My problem is the "Hello" function s.@return value always null, and I don't know why.
 
My webservice:
  1. require_once("nuSOAP/lib/nusoap.php");  
  2. $namespace = "http://merszoftkft.hu/soap/index.php?wsdl";  
  3. // create a new soap server  
  4. $server = new soap_server();  
  5. //$server->soap_defencoding = 'utf-8';  
  6. //$server->xml_encoding='utf-8';  
  7. //$server->decode_utf8 = false;  
  8. //$server->encode_utf8 = true;  
  9. //$server->charencoding=true;  
  10. // configure our WSDL  
  11. $server->configureWSDL('TorzsadatLookup'$namespace);  
  12. // set our namespace  
  13. //$server->wsdl->schemaTargetNamespace = $namespace;  
  14. $server->wsdl->addComplexType('tResult','complexType','struct','all','',  
  15. array(  
  16. 'error_code' => array('name' => 'error_code','type' => 'xsd:int'),  
  17. 'error_msg' => array('name' => 'error_msg','type' => 'xsd:string'),  
  18. 'rows_count' => array('name' => 'rows_count','type' => 'xsd:int')  
  19. ));  
  20. $server->register(  
  21. // method name:  
  22. 'ConnTest',  
  23. // parameter list:  
  24. array(),  
  25. // return value(s):  
  26. array('return'=>'tns:tResult'),  
  27. // namespace:  
  28. $namespace,  
  29. // soapaction: (use default)  
  30. false,  
  31. // style: rpc or document  
  32. 'rpc',  
  33. // use: encoded or literal  
  34. 'encoded',  
  35. // description: documentation for the method  
  36. 'Connection Test');  
  37. function ConnTest()  
  38. {  
  39. $error_code=0;  
  40. $error_msg="OK";  
  41. $rows=0;  
  42. return array('error_code'=>$error_code'error_msg'=>$error_msg'rows_count'=>$rows);  
  43. }  
  44. $server->register(  
  45. // method name:  
  46. "Hello",  
  47. // parameter list:  
  48. array('name' => 'xsd:string'),  
  49. // return value(s):  
  50. array('return'=>'xsd:string'),  
  51. // namespace:  
  52. $namespace,  
  53. // soapaction: (use default)  
  54. false,  
  55. // style: rpc or document  
  56. 'rpc',  
  57. // use: encoded or literal  
  58. 'literal',  
  59. // description: documentation for the method  
  60. 'Connection Test');  
  61. function Hello($name)  
  62. {  
  63. return "Hello " .$name;  
  64. }  
  65. // Get our posted data if the service is being consumed  
  66. // otherwise leave this data blank.  
  67. $POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA'])  
  68. $GLOBALS['HTTP_RAW_POST_DATA'] : '';  
  69. // pass our posted data (or nothing) to the soap service  
  70. $server->service($POST_DATA);  
  71. exit();  
  72. ?>  
My code:
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Linq;  
  5. using System.Text;  
  6. using System.Threading.Tasks;  
  7. using Xamarin.Forms;  
  8. using System.Data;  
  9. using Microsoft.Data.SqlClient;  
  10. using System.Net.NetworkInformation;  
  11. using System.ServiceModel;  
  12. using System.Collections.ObjectModel;  
  13. namespace App3  
  14. {  
  15. public partial class MainPage : ContentPage  
  16. {  
  17. public MainPage()  
  18. {  
  19. InitializeComponent();  
  20. }  
  21. private void Button_Clicked(object sender, EventArgs e)  
  22. {  
  23. BasicHttpBinding binding = new BasicHttpBinding()  
  24. {  
  25. Name = "basicHttpBinding",  
  26. MaxBufferSize = 2147483647,  
  27. MaxReceivedMessageSize = 2147483647,  
  28. TransferMode = TransferMode.StreamedRequest  
  29. };  
  30. TimeSpan timeout = new TimeSpan(0, 0, 30);  
  31. binding.SendTimeout = timeout;  
  32. binding.OpenTimeout = timeout;  
  33. binding.ReceiveTimeout = timeout;  
  34. ServiceReference1.TorzsadatLookupPortTypeClient cl = new ServiceReference1.TorzsadatLookupPortTypeClient(binding, new EndpointAddress("http://merszoftkft.hu/soap/index.php?wsdl"));  
  35. ServiceReference1.HelloRequest hr = new ServiceReference1.HelloRequest()  
  36. {  
  37. name = "Joe"  
  38. };  
  39. ServiceReference1.HelloResponse s = cl.Hello(hr);  
  40. if (s!=null)  
  41. {  
  42. webserviceResultLabel.Text = s.@return;  
  43. }  
  44. }  
  45. }  
  46. }  
 

Answers (6)