WEB-Services / SOAP

Moderators: None (Apply to moderate this forum)
Number of threads: 108
Number of posts: 139

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
how to call php web service from .aspx without adding Web Preference? Posted by sangtech on 17 Jun 2010 at 7:04 PM
I have a following php web service (nusoap-server-struct.php):
<?php
require_once('lib/nusoap.php');
$server = new nusoap_server();
$server->configureWSDL('hellowsdl2', 'urn:hellowsdl2');
$server->wsdl->addComplexType(
'SweepstakesGreeting',
'complexType',
'struct',
'all',
'',
array(
'greeting' => array('name' => 'greeting', 'type' => 'xsd:string'),
'winner' => array('name' => 'winner', 'type' => 'xsd:boolean')
)
);

$server->register('hello1', // method name
array('name' => 'xsd:string'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:hellowsdl2', // namespace
'urn:hellowsdl2#hello', // soapaction
'rpc', // style
'encoded', // use
'Say hello' // documentation
);

$server->register('hello2', // method name
array('name' => 'xsd:string'), // input parameters
array('return' => 'tns:SweepstakesGreeting'), // output parameters
'urn:hellowsdl2', // namespace
'urn:hellowsdl2#hello', // soapaction
'rpc', // style
'encoded', // use
'Greet a person entering the sweepstakes' // documentation
);

function hello1($name) {
return 'Hello, ' . $name;
}

function hello2($name) {
$greeting = 'Hello, ' . $name;

$winner = $name == 'Sang';

return array(
'greeting' => $greeting,
'winner' => $winner
);
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>

I’ve consumed this php web service successfully with php web service client (using nusoap client)
Now, I want to consume this php web service by C# web service client without Adding Web Preference. So, I’ve added a class WebServiceInvoker (this class allow Add Dynamic Web Reference ) to call all remote methods. And I put some codes into .aspx.cs:

WebServiceInvoker invoker;
Protected void Page_Load(object sender,EventArgs e)
{
invoker = new WebServiceInvoker(new Uri(http://service2.sample.org/ nusoap-server-struct.php));
object [] args = {“sang”};
String result1 = invoker.InvokeMethod<String>(“hellowsdl2”,”hello1”,args);
Label1.Text = result1;
}
And I’ve got the successfull call.
Now, I want to call “hello2” method, but it return a struct . So, I can’t call it from my C# web service client.
Can any body help my call “hello2” method!
Regard!


-DTS-



Attachment: SourceCode.zip (4792 Bytes | downloaded 196 times)
Report
php web service Posted by annyphp on 11 Jan 2011 at 11:02 PM
More php web service scripts listed on the page!




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.