NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Problem accessing .NET webservice with php


Joined: 12 Mar 2007
Posts: 2
Reply with quote
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
View user's profileFind all posts by jkerschSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
"doesnt work" sounds pretty unclear.
what is the actual problem?
Do you get errors or what?
Did you check the content of soap requests that are comming to the server side?
Are they comming at all?

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 12 Mar 2007
Posts: 2
Reply with quote
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 Wink
regards
jkersch
View user's profileFind all posts by jkerschSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
I think it's a nusoap 'feature'.
we always wrap parameters with this "extra" array.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
I too am stuck on the "parameters" node


Joined: 28 Jun 2006
Posts: 92
Reply with quote
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:
Code:
<?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:
Code:
<?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)
View user's profileFind all posts by bcswebstudioSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
probably you need to put findPeoplePrivileged into tns namespace.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 28 Jun 2006
Posts: 92
Reply with quote
That's what I think, too, but I honestly can't seem to crack it.. Can you point me to more examples of how to configure the paramters of nusoap construction/call?
View user's profileFind all posts by bcswebstudioSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
When nusoap creates SOAP-ENV, it walks through WSDL provided. Probably you have a malformed or incomplete wsdl.
You may try nusoap samples for the server side and check WSDL that nusoap 'likes' Smile

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
wsdl is fine.. can't format client request


Joined: 28 Jun 2006
Posts: 92
Reply with quote
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


Code:
<?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>
View user's profileFind all posts by bcswebstudioSend private message


Joined: 28 Jun 2006
Posts: 92
Reply with quote
ah-- nusoap is not a nusphere product.. I will take my questions elsewhere more appropriate-- sorry for the confusion.
(but if you happen to have any solutions to my Q, by all means, I'm all ears!)
View user's profileFind all posts by bcswebstudioSend private message
getting somewhere!


Joined: 28 Jun 2006
Posts: 92
Reply with quote
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:

Code:
$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
View user's profileFind all posts by bcswebstudioSend private message
getting nusoap.php classes to work with JAX-WS in php5


Joined: 28 Jun 2006
Posts: 92
Reply with quote
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).

Code:
$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
View user's profileFind all posts by bcswebstudioSend private message
Problem accessing .NET webservice with php
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  

  
  
 Reply to topic