473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Creation a simpliest web service

Hi all
I'm too newbie in web services so I can't figure out what the error I
made.
I have a SOAP server written in PHP:
<?php
// Define the method as a PHP function
function hello($name) {
return 'Hello, ' . $name;
}
// Pull in the NuSOAP code
//require_once('../../nusoap/lib/nusoap.php');
// Create the server instance
$server = new SoapServer('server.wsdl');
// Register the method to expose
$server->addFunction('hello');
// Use the request to (try to) invoke the service

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ?
$HTTP_RAW_POST_DATA : '';

if ($_SERVER['REQUEST_METHOD'] == "POST")
{
$server->handle();
}
else
{
$functions = $server->getFunctions();
foreach($functions as $func)
{
echo "$func<br>";
}
}
?>

The service is described by WSDL file:

<?xml version="1.0" encoding="utf-8"?>
<definitions name="HelloService"
targetNamespace="http://test-gentoo.home.local/HelloService.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://test-gentoo.home.local/HelloService.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<message name="SayHelloRequest">
<part name="firstName" type="xsd:string"/>
</message>
<message name="SayHelloResponse">
<part name="greeting" type="xsd:string"/>
</message>

<portType name="Hello_PortType">
<operation name="hello">
<input message="tns:SayHelloRequest"/>
<output message="tns:SayHelloResponse"/>
</operation>
</portType>

<binding name="Hello_Binding" type="tns:Hello_PortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/
soap/http"/>
<operation name="hello">
<soap:operation soapAction="urn:examples:helloservice"/>
<input>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:helloservice"
use="encoded"/>
</input>
<output>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:helloservice"
use="encoded"/>
</output>
</operation>
</binding>

<service name="Hello_Service">
<documentation>WSDL File for HelloService</documentation>
<port binding="tns:Hello_Binding" name="Hello_Port">
<soap:address location="http://192.168.0.102/web-services/soap/
server.php" />
</port>
</service>
</definitions>

Using wsdl.exe I have created a proxy class for this service. The
invocation of the service's method looks like this:

static void Main(string[] args)
{
Hello_Service client = new Hello_Service();
Console.WriteLine(client.hello("test"));
}

The request sent to the server looks like this:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/
encoding/"
xmlns:tns="http://test-gentoo.home.local/
HelloService.wsdl"
xmlns:types="http://test-gentoo.home.local/
HelloService.wsdl/encodedTypes"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/
encoding/">
<q1:hello xmlns:q1="urn:examples:helloservice">
<firstName xsi:type="xsd:string">test</firstName>
</q1:hello>
</soap:Body>
</soap:Envelope>

.... and response looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/
envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Bad Request</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I can't understand where mistake is. I checked the request according
to SOAP specification - seems like it's correct. Did I miss anything?

Thank you in advance.
Mykhaylo.

Jun 2 '07 #1
0 1588

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Will Arrowsmith | last post by:
Hi All, I am aiming to create a multiframe Tiff file that I can fax using the windows fax service FAXCOMLib. I have created an array of Bitmaps (pages I want in my fax doc) and succesfully...
0
by: RJ | last post by:
I saw an article on MSDN knowledge base that explains how to use a SQLXML tool ( IIS Configuration ) to select a stored procedure and generate a web service wrapper. I noticed that the example to...
14
by: Bert Vandenberghe | last post by:
Hi, I was wondering if there are any best practices on the creation of webmethods? I'll try to explain this a little more: My problem is that we are changing an existing (large) DCOM application...
8
by: Ankit Aneja | last post by:
Hi I have made a windows service in C#.Net Now I want to create a setup of this service http://www.codeproject.com/dotnet/simplewindowsservice.asp I read this article Now my service is also using...
1
by: Enrico Foschi | last post by:
GoodMorning, I'm an italian developer, so, first of all, excuse me for my poor and incorrect english. I am writing here hoping to find some advice for a procedure that a like to create: I...
3
by: Limunski Magarac | last post by:
Hi all :) My apologies if I posted in the wrong groups, but I just jumped in MS SQL waters, so any guidance will be appreciated. What I'm trying to do is the following process: present...
1
by: mitrofun63 | last post by:
Hi, All I have trouble with db2 instance creation (DB2 9.1.2 on AIX 5.3) When i run command for instance creation : ../db2icrt -a SERVER -p 50000 -s ese -u db2fenc1 db2inst1 a reciveve...
2
by: =?Utf-8?B?am9obnByZW1p?= | last post by:
Hi there, I have a web app that adds user into w2k3 server and adds it to the administrator group. The code snippet is something like this: try { DirectoryEntry AD = new...
0
by: =?Utf-8?B?U2ViYXN0aWFuIEZyw6Ruaw==?= | last post by:
In several locations in the MSDN Mappoint Web Service SDK it says: "Creating Polygons There are several ways you can create and prepare polygon data for upload to the Customer Service Site: 1....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.