troubleshooting Question

Web Service AuthenticationHeader VB.net - PHP

Avatar of SweLogan
SweLogan asked on
Web Languages and StandardsPHP
1 Comment1 Solution780 ViewsLast Modified:
Hi, new here at Experts Exchange, I'm about to build an API in VB.NET which is called from a PHP page.

I got HelloWorld() work. But GetData() is not working!  Can't see any Error message.

My point of this question is how do I enter information in SoapHeader with "Service1.asmx?WSDL?&UserID=AdminPassword=Admin" And then use this to keep track of user?
========= VB.NET CODE ========= 
Public Class Service1
    Inherits System.Web.Services.WebService
 
    'class that inherits from SoapHeader
    Public Class MyHeader
        Inherits SoapHeader
        Public UserID As String
        Public Password As String
    End Class
 
    'instance of soap header class
    'this will be populated by client and send back
 
    Public objMyHeader As MyHeader
 
    'set soap header details
 
    <WebMethod(), SoapHeader("objMyHeader", direction:=SoapHeaderDirection.InOut)> Public Function GetData() As String
        If objMyHeader.UserID = "Admin" And objMyHeader.Password = "Admin" Then
            Return "Valid user"
            ''Call your second method here
        Else
            Return "Invalid user"
        End If
    End Function
 
    <WebMethod()> Public Function HelloWorld() As String
        Return "Hello World"
    End Function
End Class
 
========= PHP CODE ========= 
<?php
try {
	$serviceUrl = "http://localhost:53719/Service1.asmx";
	
	$client = new SoapClient($serviceUrl . "?WSDL",
	array("location" => $serviceUrl . 
	"?UserID=Admin&Password=Admin"));
	$objectresult = $client->GetData();
 
} catch(SoapFault $soapFault) {
	echo "Error: " . $soapFault->faultstring;
}
?>
 
========= SOAP CODE ========= 
<?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:Header>
    <MyHeader xmlns="http://tempuri.org/">
      <UserID>string</UserID>
      <Password>string</Password>
    </MyHeader>
  </soap:Header>
  <soap:Body>
    <GetData xmlns="http://tempuri.org/" />
  </soap:Body>
</soap:Envelope>
ASKER CERTIFIED SOLUTION
SweLogan

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros