Article

From:
To:
Dann Croghan
Subject:
Re: WSDL - Cannot Unwrap issues [Edit]
Newsgroup:
embarcadero.public.delphi.webservices

Re: WSDL - Cannot Unwrap issues [Edit]

Hello,

I just spent a few minutes on this and, yes, if I'm reading this WSDL correctly, indeed the Service requires WS-Addressing. The top level WSDLs contains not Policy elements but if you look at the other WSDL, https://tapstaging.tax.utah.gov/efile/MFET/WSDL/?wsdl=wsdl0, imported from the top-level one you'll see the following:
{code}   <wsp:Policy wsu:Id="WSHttpBinding_MFET_policy">     <wsp:ExactlyOne>       <wsp:All>         <wsaw:UsingAddressing />       </wsp:All>     </wsp:ExactlyOne>   </wsp:Policy> {code}
I'll come back to WS-Addressing later. Each operation exposed by the Service also expects a MFETHeader. Here's how you set this header:
{code} procedure TForm16.Button1Click(Sender: TObject); var   AMFETHeader: MFETHeader;   AService: MFET;   ASubmissionList: SubmissionList;   I: Integer; begin   AMFETHeader := MFETHeader.Create;   try     AMFETHeader.User := 'user';     AMFETHeader.Password := 'password';     AMFETHeader.Environment := EnvironmentType.P;
    AService := GetMFET(False, '', HTTPRIO1);     (AService as ISOAPHeaders).Send(AMFETHeader);
    ASubmissionList := AService.SubmissionListBySubmissionId('100');     try       // Here process response     finally       for I := 0 to Length(ASubmissionList)-1 do         ASubmissionList[I].Free;     end;   finally     AMFETHeader.Free;   end; end; {code}

If you hook the OnBeforeExecute event on the RIO you'll see that the above calls generates the following request:
{code} <?xml version="1.0"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">   <SOAP-ENV:Header>     <NS1:MFETHeader xmlns:NS1="http://www.fastenterprises.com">       <NS1:User>user</NS1:User>       <NS1:Password>password</NS1:Password>       <NS1:Environment>P</NS1:Environment>     </NS1:MFETHeader>   </SOAP-ENV:Header>   <SOAP-ENV:Body>     <SubmissionId xmlns="http://www.fastenterprises.com">100</SubmissionId>   </SOAP-ENV:Body> </SOAP-ENV:Envelope> {code}

Adjust the user/password and Environment appropriately.
But the above will still generate the error you received because that error, as I suspected, is not about a missing MFEFHeader but rather that the Service requires WS-Addressing. I suspect that the service probably wants the minimal WS-Addressing header: with 'To', 'Action', 'MessageID' and (maybe) 'ReplyTo'. Automatic handling of WS-Addressing is something we plan to add to Delphi SOAP. For now, when required, it has to be handled manually.
I tried to add a manual WS-Addressing header. First I added the 'Action' - which is what the service complained about. Once that was done, it complained about the 'To' item. I added that one, and a MessageID. At that point the Service simply returns 400 (Bad Request). So it seems that I'm getting through the WS-Addressing issues. I'm hoping that '400' is the way the Service says "You don't have a valid user/password or submissionId for me to process"... although I can't really confirm this. Here's the request I sent:
{code} <?xml version="1.0"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">   <SOAP-ENV:Header xmlns:wsa='http://www.w3.org/2005/08/addressing'>
<wsa:Action>http://www.fastenterprises.com/MFET/SubmissionListBySubmissionId</wsa:Action>
    <wsa:To>
        <wsa:Address>https://tapstaging.tax.utah.gov/efile/MFET</wsa:Address>
    </wsa:To>
    <wsa:MessageID>13F6D3EE-B4C1-4CD8-A16B-BC1852C31D7D</wsa:MessageID>
    <NS1:MFETHeader xmlns:NS1="http://www.fastenterprises.com">
      <NS1:User>user</NS1:User>
      <NS1:Password>password</NS1:Password>
      <NS1:Environment>P</NS1:Environment>
    </NS1:MFETHeader>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <SubmissionId xmlns="http://www.fastenterprises.com">100</SubmissionId>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
{code}

The 'Action' has to match the SOAPAction of the method you're invoking. In the case of this Service, you'll see that the importer generated the following line:
{code}   InvRegistry.RegisterDefaultSOAPAction(TypeInfo(MFET), 'http://www.fastenterprises.com/MFET/%operationName%'); {code}
So you just have to substitute %operationName% for whatever operation/method you are invoking.
The 'To' must be the URL to which we're sending requests. You can find that value again in the code generated by the importer:
{code} function GetMFET(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): MFET; const   defWSDL = 'https://tapstaging.tax.utah.gov/efile/MFET/WSDL/?wsdl';   defURL = 'https://tapstaging.tax.utah.gov/efile/MFET';   defSvc = 'MFET';   defPrt = 'WSHttpBinding_MFET'; {code}
It's the 'defURL' constant that's needed.
The MessageID must be a unique identifier - so I just create a GUID.
If you have a valid user/password/submissionId and can try the above, please let me know if that worked for you.
Cheers,
Bruneau
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Sat, 27 Jul 2024 03:14:40 UTC
Copyright © 2009-2024
HREF Tools Corp.