Soap Server with .net type Soap Header Authentication |
Reply from Scott at sourceforge |
|
Hi,
I am posting the reply below that I got from Scott Nichol at sourceforge for the benefit of others asking the same question. I hope that's ok. Please add more to this thread if you have any input. Thank you. -a RE: nuSoap Server with .net type Soap Header (New) By: Scott Nichol (snichol) - 2008-04-08 09:00 There are a couple of instance variables in the nusoap_server class that allow you to access SOAP Headers. Most generally, requestSOAP gives you the full SOAP request (the HTTP payload) as a string. You can then parse anything out of it that you want. The requestHeaders variable gives you just the SOAP headers in string form, with a caveat: namespace resolution is spotty or nonexistent. Finally, requestHeader gives you the headers parsed into associative arrays, similar to what you get as a return value from the call method of nusoap_client. Your code might look like this (with no error checking):
RE: nuSoap Server with .net type Soap Header (New) By: bit wit (bit_wit) - 2008-04-09 01:18 Hi Scott, I am not sure yet what the issues will be about the namespace, but I will try what you suggested. Thank you for answering me. -a |
||||||||||||||
|
Reply from Scott at sourceforge |
|
Hi, thanks for details.
I tried to transfer SOAP header from .NET client to PHP web service as this method was described in this post. But instead login and password values on server side I have that $server->requestHeader is invalid expression in watch window. Why? Thanks for any help! PHP version is 5.2.5, Apache version is 2.2. PHP web service is the same. .NET client:
|
||||||||||||||
|
.NET NuSoap Header Athentication problem |
|
Hi everybody
I have found a way to do a personal authentication on a web service. In the soap header message, you can set nodes with that information. So, each time the client consume a web service, he/she must athuenticate him/her self. Now, the problem is that don't work forme. T-T Check the exaple at the bottom, http://msdn.microsoft.com/es-es/library/8728chd5.aspx (in spanish) Now, I did a web service that brings the user name seted inside the header, the problem is that is not founded. This. is my web service: MyWebService.asmx Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.ComponentModel ' Define a SOAP header by deriving from the SoapHeader base class. Public Class Header : Inherits SoapHeader Public Username As String Public Password As String End Class ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. <System.Web.Script.Services.ScriptService()> _ <System.Web.Services.WebService(Namespace:="http://tempuri_org/")> _ <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ <ToolboxItem(False)> _ Public Class MyWebService ' Add a member variable of the type deriving from SoapHeader. Public myHeaderMemberVariable As Header ' Apply a SoapHeader attribute. <WebMethod(), SoapHeader("myHeaderMemberVariable")> _ Public Function MyWebMethod() As String ' Process the SoapHeader. Return myHeaderMemberVariable.Username End Function End Class My test file: test1.php <?php require_once('nusoap_0-7-3/lib/nusoap.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Probando los Web Services desde PHP</title> </head> <body> <?php $wsdl = 'http://localhost/ws/MyWebService.asmx?WSDL'; $method = 'MyWebMethod'; $params = array(); $client = new nusoap_client($wsdl, 'wsdl'); //$client->response_timeout = 600; $client->soap_defencoding = 'UTF-8'; $client -> setHeaders(' <Header> <Username>myUserName</Username> <Password>myPassword</Password> </Header> '); $err = $client->getError(); //echo "<br/> proxyport =".htmlspecialchars($client->$proxyhost)."<br/>"; if ($err) { echo '<h2>Error del contructor</h2><pre>' . $err . '</pre>'; echo '<h2>Debug:</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>'; exit(); } $result = $client->call($method, $params); if ($client->fault) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } else { $err = $client->getError(); if ($err) { echo '<h2>Error</h2><pre>' . $err . '</pre>'; } else { echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>'; } } echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>'; ?> </body> </html> My Issue 0_o Fault Array ( [faultcode] => soap:Server [faultstring] => System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object. at meals_ws_application.MyWebService.MyWebMethod() in C:\Documents and Settings\ingenieria\Mis documentos\Visual Studio 10\Projects\ws\meals-ws-application\MyWebService.asmx.vb:line 25 --- End of inner exception stack trace --- [detail] => ) Request POST /ws/MyWebService.asmx HTTP/1.0 Host: localhost User-Agent: NuSOAP/0.7.3 (1.114) Content-Type: text/xml; charset=UTF-8 SOAPAction: "http://tempuri_org/MyWebMethod" Content-Length: 554 <?xml version="1.0" encoding="UTF-8"?><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:ns8315="http://tempuri_org"><SOAP-ENV:Header> <Header> <Username>myUserName</Username> <Password>myPassword</Password> </Header> </SOAP-ENV:Header><SOAP-ENV:Body><MyWebMethod xmlns="http://tempuri_org/"></MyWebMethod></SOAP-ENV:Body></SOAP-ENV:Envelope> I just want that the web service return myUserName, that's it T-T If it works I could set some encripted information. All your posts are wellcome. Regards Jorge Andrés Cañón Sierra Ingenierio de Sistemas |
||||||||||||
|
|
I don't know if you will receive this message because this forum has been inactive for some time but I had problems too. What web server would you recommend that I use to transfer the SOAP header from .NET??
Thanks, |
||||||||||||
|
|
Hi! I’ve just visited this forum. Happy to get acquainted with you. Thanks.
__________________ |
||||||||||||
|
Soap Server with .net type Soap Header Authentication |
|
||
Content © NuSphere Corp., PHP IDE team
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by