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:
- require_once("nuSOAP/lib/nusoap.php");
- $namespace = "http://merszoftkft.hu/soap/index.php?wsdl";
- // create a new soap server
- $server = new soap_server();
- //$server->soap_defencoding = 'utf-8';
- //$server->xml_encoding='utf-8';
- //$server->decode_utf8 = false;
- //$server->encode_utf8 = true;
- //$server->charencoding=true;
- // configure our WSDL
- $server->configureWSDL('TorzsadatLookup', $namespace);
- // set our namespace
- //$server->wsdl->schemaTargetNamespace = $namespace;
- $server->wsdl->addComplexType('tResult','complexType','struct','all','',
- array(
- 'error_code' => array('name' => 'error_code','type' => 'xsd:int'),
- 'error_msg' => array('name' => 'error_msg','type' => 'xsd:string'),
- 'rows_count' => array('name' => 'rows_count','type' => 'xsd:int')
- ));
- $server->register(
- // method name:
- 'ConnTest',
- // parameter list:
- array(),
- // return value(s):
- array('return'=>'tns:tResult'),
- // namespace:
- $namespace,
- // soapaction: (use default)
- false,
- // style: rpc or document
- 'rpc',
- // use: encoded or literal
- 'encoded',
- // description: documentation for the method
- 'Connection Test');
- function ConnTest()
- {
- $error_code=0;
- $error_msg="OK";
- $rows=0;
- return array('error_code'=>$error_code, 'error_msg'=>$error_msg, 'rows_count'=>$rows);
- }
- $server->register(
- // method name:
- "Hello",
- // parameter list:
- array('name' => 'xsd:string'),
- // return value(s):
- array('return'=>'xsd:string'),
- // namespace:
- $namespace,
- // soapaction: (use default)
- false,
- // style: rpc or document
- 'rpc',
- // use: encoded or literal
- 'literal',
- // description: documentation for the method
- 'Connection Test');
- function Hello($name)
- {
- return "Hello " .$name;
- }
- // Get our posted data if the service is being consumed
- // otherwise leave this data blank.
- $POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA'])
- ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
- // pass our posted data (or nothing) to the soap service
- $server->service($POST_DATA);
- exit();
- ?>
My code:
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Xamarin.Forms;
- using System.Data;
- using Microsoft.Data.SqlClient;
- using System.Net.NetworkInformation;
- using System.ServiceModel;
- using System.Collections.ObjectModel;
- namespace App3
- {
- public partial class MainPage : ContentPage
- {
- public MainPage()
- {
- InitializeComponent();
- }
- private void Button_Clicked(object sender, EventArgs e)
- {
- BasicHttpBinding binding = new BasicHttpBinding()
- {
- Name = "basicHttpBinding",
- MaxBufferSize = 2147483647,
- MaxReceivedMessageSize = 2147483647,
- TransferMode = TransferMode.StreamedRequest
- };
- TimeSpan timeout = new TimeSpan(0, 0, 30);
- binding.SendTimeout = timeout;
- binding.OpenTimeout = timeout;
- binding.ReceiveTimeout = timeout;
- ServiceReference1.TorzsadatLookupPortTypeClient cl = new ServiceReference1.TorzsadatLookupPortTypeClient(binding, new EndpointAddress("http://merszoftkft.hu/soap/index.php?wsdl"));
- ServiceReference1.HelloRequest hr = new ServiceReference1.HelloRequest()
- {
- name = "Joe"
- };
- ServiceReference1.HelloResponse s = cl.Hello(hr);
- if (s!=null)
- {
- webserviceResultLabel.Text = s.@return;
- }
- }
- }
- }
Krisztian RaczPosted Jun 10, 2021, 4:04 AM
Hi,
Here is my sample. I tried it, but doesn't work.
Suresh MPosted Jun 7, 2021, 2:52 AM
Krisztian RaczPosted Jun 5, 2021, 5:04 AM
Suresh MPosted Jun 4, 2021, 11:39 AM
Krisztian RaczPosted Jun 4, 2021, 9:55 AM
Suresh MPosted Jun 3, 2021, 8:06 PM