0

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.

rene
  • 41,474
  • 78
  • 114
  • 152
bob alston
  • 21
  • 3
  • Why did you use wsdl.exe? Do you have svcutil available and can you use that one to generate a WCF client? What is the exact exception you get? – rene Apr 01 '23 at 20:43
  • No error received. It just doesn't work. – bob alston Apr 01 '23 at 21:39
  • It is not a WCF service. – bob alston Apr 01 '23 at 21:57
  • That doesn't matter. WCF handles SOAP services, and that endpoint delivers a SOAP1.2 format, which WCF can and should handle. Given your claim that no exception is thrown I wonder if the generated code by wsdl might cause this, hence my suggestion to use svcutil. That has the added benefit of more detailed logging so you can examine what is going on the wire. – rene Apr 02 '23 at 07:30
  • Switched to WCF. Successful in getting log of sent message - looks correct except for some of the other "MessageLogTraceRecord" stuff. Hard to tell what is the ACTUAL message sent. Will compare the inside parts to ensure save as my production version (where soap is directly sent to HTTP). ON initial glance all the data fields required are there. Verified that my ID and password is still active/enabled on the host server. Suggestions for what else to check? @Rene Thanks for all your help! – bob alston Apr 02 '23 at 21:09
  • Got it working. Thanks again for your help. I have spent hours and hours on this. – bob alston Apr 03 '23 at 04:17
  • It would be appreciated if you could write an answer that describes what / how you solved it in the end. – rene Apr 03 '23 at 16:54

1 Answers1

0

Best recommendation was to switch to WCF. At the time I did not know I could use WCF to communicate with old soap/xml service. It works.

WCF allows for logging outbound message: https://learn.microsoft.com/en-us/dotnet/framework/wcf/diagnostics/configuring-message-logging This is really key as it tells me whether or not my message was actually sent. It was.

Learned to use Fiddler classic (free version) to see if I got any response.

No response til I changed "DownloadAsync" to "Download".

Had to expand max size of inbound messages for my app: The maximum message size quota for incoming messages (65536) has been exceeded

Last problem was not having proper backups of my app. I use IDrive - which was not setup to backup my Visual Studio apps (it is now) and a monthly backup to portable hard drive which fortunately was run after I switched to WCF but did not have the latest changes. In doing cleanup I INADVERTENLY deleted my app latest version. Now making more copies as I make changes and made sure IDrive was properly backing everything up.

Update 2023-04-08 8:05 pm- Original code was missing code tying header to service. Adding this line made it work:

service.CMBHSAuthenticationHeaderValue = myheader;

bob alston
  • 21
  • 3