 |
 | Problem accessing .NET webservice with php |  |
Joined: 12 Mar 2007 |
Posts: 2 |
|
|
 |
Posted: Sun Mar 11, 2007 9:24 am |
|
 |
 |
 |
 |
hi there,
i got a webservice that requires a request as followed:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<addCustomerMobile xmlns="http://tempuri_org/">
<Username>string</Username>
<Password>string</Password>
<CustomerFName>string</CustomerFName>
<CustomerLName>string</CustomerLName>
<Handsetnumber>string</Handsetnumber>
<CustomerGroup>string</CustomerGroup>
<CustomerDescription>string</CustomerDescription>
</addCustomerMobile>
</soap:Body>
</soap:Envelope>
my php to access the service (other methods from the same service work)
$params = array(
'Username' => "test",
'Password' => "test",
'CustomerFName' => "testname1",
'CustomerLName' => "testname1b",
'Handsetnumber' => "test",
'CustomerGroup' => "test",
'CustomerDescription'=> "testcustdescr"
);
print_r( $client->call('addCustomerMobile',$params));
where test/test are username/password credentials in a plain text string.
the problem is, when i try to consume the service from within a c# client application, it works without problems (with the same supplied data) but it doesnt work from within php. the service uses utf-8 as encoding. the same as my php client does.
i guessed that there were some problems with strings, but i was wrong. i have no idea what the problem might be.
any ideas?
thanks in advance
jkersch
|
|
 |
 | |  |
Joined: 12 Mar 2007 |
Posts: 2 |
|
|
 |
Posted: Mon Mar 12, 2007 4:40 pm |
|
 |
 |
 |
 |
i did get responses in soap format, however, i solved the problem.
.NET webservices wrap all the parameters in an array called parameters.
when i changed
$client->call('addCustomerMobile',$params);
to
$client->call('addCustomerMobile',array('parameters'=>$params));
it worked. thanks nevertheless
regards
jkersch
|
|
 | I too am stuck on the "parameters" node |  |
Joined: 28 Jun 2006 |
Posts: 92 |
|
|
 |
Posted: Thu Mar 15, 2007 9:37 am |
|
 |
 |
 |
 |
I have a similar problem, but the other way around: How do I actually change that "parameters" node to instead be the name of my remote method to be called?
I have a wsdl which I am not posting yet unless needed. Instead, here is a call known to work from the ws ?tester utility:
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header/>
<S:Body>
<ns2:findPeoplePrivileged xmlns:ns2="http://beans.ejb.ldap.brazos/">
<arg0>ou=info*</arg0>
</ns2:findPeoplePrivileged>
</S:Body>
</S:Envelope> |
And here is all I'm able to get my nusoap code to produce:
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://beans.ejb.ldap.brazos/">
<SOAP-ENV:Body>
<parameters>
<arg0 xmlns="">ou=info*</arg0>
</parameters>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>"
|
Things I think I need to get to work (and need help on!):
- how to declare my namespace without editing nusoap.php*
- how to get my declared namespace into the, currently, "parameters" node like in the first example above
- how to get the "parameters" node to instead be the name of the method called, namely, "findPeoplePrivileged"?
* side note: the line xmlns:tns="http://beans.ejb.ldap.brazos/" on this particular run was modified at runtime while stepping thru the debugger (awesome IDE)
|
|
 |
 | |  |
 | wsdl is fine.. can't format client request |  |
Joined: 28 Jun 2006 |
Posts: 92 |
|
|
 |
Posted: Tue Mar 20, 2007 8:51 am |
|
 |
 |
 |
 |
dmitri-
the wsdl is fine (posted below for inspection). What I lack is a better understanding of what parameters must be used to instruct nusoap to generate the client request that my web service requires. I'm certain it must be a trivial solution. Also, I am not 100% confident my own find/replace mentioned above to work around the naming conflict with "soap" in php5 is not perhaps interfering-- hence the request for an official dmitri-released nusoap.php.
Do I need to mess with anything within nusoap.php, or is everything I need to do available via instantiation parameters?
thanks!
-bronius
<?xml version="1.0" encoding="utf-8"?><definitions xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://beans.ejb.ldap.brazos/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://beans.ejb.ldap.brazos/" name="DirectoryBeanService"><types><xsd:schema><xsd:import namespace="http://beans.ejb.ldap.brazos/" schemaLocation="http://dev3:8080/DirectoryBeanService/DirectoryBean?xsd=1"></xsd:import></xsd:schema></types><message name="findPeoplePrivileged"><part name="parameters" element="tns:findPeoplePrivileged"></part></message><message name="findPeoplePrivilegedResponse"><part name="parameters" element="tns:findPeoplePrivilegedResponse"></part></message><message name="SOAPException"><part name="fault" element="tns:SOAPException"></part></message><message name="findPersonPrivileged"><part name="parameters" element="tns:findPersonPrivileged"></part></message><message name="findPersonPrivilegedResponse"><part name="parameters" element="tns:findPersonPrivilegedResponse"></part></message><portType name="DirectoryBean"><operation name="findPeoplePrivileged"><input message="tns:findPeoplePrivileged"></input><output message="tns:findPeoplePrivilegedResponse"></output><fault message="tns:SOAPException" name="SOAPException"></fault></operation><operation name="findPersonPrivileged"><input message="tns:findPersonPrivileged"></input><output message="tns:findPersonPrivilegedResponse"></output><fault message="tns:SOAPException" name="SOAPException"></fault></operation></portType><binding name="DirectoryBeanPortBinding" type="tns:DirectoryBean"><soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding><operation name="findPeoplePrivileged"><soap:operation soapAction=""></soap:operation><input><soap:body use="literal"></soap:body></input><output><soap:body use="literal"></soap:body></output><fault name="SOAPException"><soap:fault name="SOAPException" use="literal"></soap:fault></fault></operation><operation name="findPersonPrivileged"><soap:operation soapAction=""></soap:operation><input><soap:body use="literal"></soap:body></input><output><soap:body use="literal"></soap:body></output><fault name="SOAPException"><soap:fault name="SOAPException" use="literal"></soap:fault></fault></operation></binding><service name="DirectoryBeanService"><port name="DirectoryBeanPort" binding="tns:DirectoryBeanPortBinding"><soap:address location="http://dev3:8080/DirectoryBeanService/DirectoryBean"></soap:address></port></service></definitions> |
|
|
 |
 | |  |
 | getting somewhere! |  |
Joined: 28 Jun 2006 |
Posts: 92 |
|
|
 |
Posted: Tue Mar 20, 2007 1:32 pm |
|
 |
 |
 |
 |
Ok (posting for the general public's knowledge), I'm getting somewhere now. Now, my client request is generating a properly formed xml document with the web service method's name being the request element name and the "arg0" arguments replacing the "<parameter />" tag. The issue (thus far) was that the wizard-generated client request code didn't clue me in to separating the wsdl from the web service server/url:
$mysoap = new soapclientPE("http://dev3:8080/DirectoryBeanService/DirectoryBean?tester", true, "http://dev3:8080/DirectoryBeanService/DirectoryBean?wsdl"); |
The first param is the web service server, the "true" says, "Yes, I'm passing in a wsdl," and the third param is the url of the wsdl. Before, all I sent as params was the wsdl url as guided by the wizard.
hth
|
|
 | getting nusoap.php classes to work with JAX-WS in php5 |  |
Joined: 28 Jun 2006 |
Posts: 92 |
|
|
 |
Posted: Tue Mar 20, 2007 2:31 pm |
|
 |
 |
 |
 |
Ok, I got my web service to work in php5 (requiring renaming of "soapclient" in nusoap.php to "soapclientPE" (my chosen name)) in order to consume a typical, well-formed web service as produced by JAX-WS. There was one ticky trick, and that was that for some reason, my "endpoint" (first param in class instantiation) required a trailing query that was neither ?wsdl nor ?tester (both of which, in my case at least) are reserved for other functionality. However, without that trailing "?" and either nothing or any string not wsdl nor tester, the call would hang (and probably timeout, but I am impatient).
$mysoap = new soapclientPE("http://dev3:8080/DirectoryBeanService/DirectoryBean?", false);
// set parameter parameters (findPeoplePrivileged)
$parameters = array("arg0"=>"ou=info*");
$result = $mysoap->call("findPeoplePrivileged", $parameters, "http://beans.server.ldap.brazos/");
|
What I lacked before was:
a "?" or "?something" trailing my "endpoint" (whereas before, I was trying to pass in the wsdl url itself)
passing in the required namespace in the call to $mysoap->call()
quotes around the name "arg0" in list of arguments/parameters
hope this helps someone
-bronius
|
|
 |
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
All times are GMT - 5 Hours
Page 1 of 2
|
|
|
|  |