Click here to Skip to main content
15,885,546 members
Home / Discussions / Web Development
   

Web Development

 
QuestionASP Pin
rajiv_kadam25-Aug-09 23:04
rajiv_kadam25-Aug-09 23:04 
AnswerRe: ASP Pin
Not Active26-Aug-09 2:18
mentorNot Active26-Aug-09 2:18 
JokeRe: ASP Pin
Arun Jacob27-Aug-09 1:08
Arun Jacob27-Aug-09 1:08 
AnswerRe: ASP Pin
Jeremy Likness27-Aug-09 6:26
professionalJeremy Likness27-Aug-09 6:26 
Questionasp Pin
rajiv_kadam25-Aug-09 21:40
rajiv_kadam25-Aug-09 21:40 
AnswerRe: asp Pin
Marc Firth25-Aug-09 22:20
Marc Firth25-Aug-09 22:20 
AnswerRe: asp Pin
Marc Firth25-Aug-09 22:21
Marc Firth25-Aug-09 22:21 
QuestionNuSOAP setHeaders problem Pin
Jorge Cañón25-Aug-09 10:59
Jorge Cañón25-Aug-09 10:59 
Hello Big Grin | :-D

I found this page: http://msdn.microsoft.com/es-es/library/8728chd5.aspx



I want to get the user name and the password in the web service but I can not. Sigh | :sigh:

Anyone knows how can I do it? These are my files:


***********************************************************************
***********************************************************************
MyWebService.asmx.vb
***********************************************************************
***********************************************************************



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 MyHeader : 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 MyHeader

' Apply a SoapHeader attribute.
<WebMethod(), SoapHeader("myHeaderMemberVariable")> _
Public Function MyWebMethod() As String
' Process the SoapHeader.
Return myHeaderMemberVariable.Username
End Function
End Class


***********************************************************************
***********************************************************************
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('
<MyHeader>
<Username>myUserName</Username>
<Password>myPassword</Password>
</MyHeader>
');
$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>


***********************************************************************
***********************************************************************
The error:
***********************************************************************
***********************************************************************
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:ns4181="http://tempuri.org"><SOAP-ENV:Header>
<MyHeader>
<Username>Admin</Username>
<Password>contrasenia</Password>
</MyHeader>
</SOAP-ENV:Header><SOAP-ENV:Body><MyWebMethod xmlns="http://tempuri.org/"></MyWebMethod></SOAP-ENV:Body></SOAP-ENV:Envelope>

Thanks for your help.
Questionpicture not shown in runtime (.net) Pin
m.samar25-Aug-09 2:15
m.samar25-Aug-09 2:15 
QuestionRe: picture not shown in runtime (.net) Pin
ali_reza_zareian25-Aug-09 20:37
ali_reza_zareian25-Aug-09 20:37 
AnswerRe: picture not shown in runtime (.net) Pin
m.samar25-Aug-09 23:33
m.samar25-Aug-09 23:33 
QuestionRe: picture not shown in runtime (.net) Pin
Adam Maras27-Aug-09 23:22
Adam Maras27-Aug-09 23:22 
AnswerRe: picture not shown in runtime (.net) Pin
m.samar28-Aug-09 17:55
m.samar28-Aug-09 17:55 
QuestionHow to get printer status and print MS word document using javascript? Pin
Gokul Raja198724-Aug-09 6:03
Gokul Raja198724-Aug-09 6:03 
AnswerRe: How to get printer status and print MS word document using javascript? Pin
sunfruit25-Nov-10 20:50
sunfruit25-Nov-10 20:50 
QuestionHow to get MS word document page settings and number of pages using JavaScript? Pin
Gokul Raja198724-Aug-09 5:49
Gokul Raja198724-Aug-09 5:49 
AnswerRe: How to get MS word document page settings and number of pages using JavaScript? Pin
Gokul Raja198717-Sep-09 8:25
Gokul Raja198717-Sep-09 8:25 
QuestionHow to kill the process of website in c# Pin
Rajesh_K_Sharma24-Aug-09 0:28
Rajesh_K_Sharma24-Aug-09 0:28 
AnswerRe: How to kill the process of website in c# Pin
SeMartens24-Aug-09 20:40
SeMartens24-Aug-09 20:40 
Questionhow can i send a byte array from client side to server side Pin
subramanian.rtechconet23-Aug-09 23:00
subramanian.rtechconet23-Aug-09 23:00 
QuestionDisable Print Screen Option Pin
Aman Bhullar21-Aug-09 20:13
Aman Bhullar21-Aug-09 20:13 
QuestionDrawing a box around an arbitrary HTML block Pin
astibich221-Aug-09 15:00
astibich221-Aug-09 15:00 
QuestionElegant use of the CSS padding property Pin
jesarg21-Aug-09 8:03
jesarg21-Aug-09 8:03 
AnswerRe: Elegant use of the CSS padding property Pin
jesarg21-Aug-09 8:10
jesarg21-Aug-09 8:10 
Question"best" Blog for text publishing ? Pin
Maximilien21-Aug-09 5:21
Maximilien21-Aug-09 5:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.