I used WSDL to generate classes for creating a soap/XML message to a web service. WSDL: https://cmbhs.dshs.state.tx.us/cmbhswebservice/Service/DataDownloadService.asmx?wsdl
soap/xml request that works when using another language/HTTP submission:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<CMBHSAuthenticationHeader xmlns="http://www.dshs.state.tx.us/cmbhs/">
<CMBHSUserName>xxxx</CMBHSUserName>
<CMBHSPassword>yyyy</CMBHSPassword>
</CMBHSAuthenticationHeader>
</soap:Header>
<soap:Body>
<Download xmlns="http://www.dshs.state.tx.us/cmbhs/">
<organizationNbr>479</organizationNbr>
<fromDate>##########</fromDate>
<toDate>$$$$$$$$$$</toDate>
<downloadType>##</downloadType>
<downloadDateType>2</downloadDateType>
</Download>
</soap:Body>
</soap:Envelope>
What seems to make this complicated is the use of a mandatory authentication header.
My code is as follows(real ID, password removed):
using ConsoleApp7.us.tx.state.dshs.cmbhs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using System.Web.Services.Description;
using static System.Collections.Specialized.BitVector32;
namespace ConsoleApp7
{
internal class Program
{
static void Main(string[] args)
{
var service = new us.tx.state.dshs.cmbhs.DataDownloadService { Url= "https://cmbhs.dshs.state.tx.us/cmbhswebservice/Service/DataDownloadService.asmx" };
CMBHSAuthenticationHeader myheader = new CMBHSAuthenticationHeader();
myheader.CMBHSUserName = "xxxxxx";
myheader.CMBHSPassword = "yyyyyy";
Console.WriteLine("location 1");
DateTime FromDate = new DateTime(2022, 10, 01);
DateTime ToDate = new DateTime(2022, 10, 03);
Console.WriteLine("location 2");
DataDownloadResult mydata = service.Download(449737,FromDate ,ToDate , 12, 02);
Console.WriteLine("----START----");
Console.WriteLine(mydata);
Console.WriteLine("----END----");
}
}
}
When I run the code, the Location 1 and Location 2 messages are displayed but not the "----START----" message.
Can anyone tell me what is wrong or how to figure out what is wrong?
I have read extensively and tried a host of different object and variable names.