[External] ValidaXML_AIFM(VAR _XMLToValidate : Text;VAR _Error : Text) RetVal : Boolean IF NOT TryValidate(XMLDoc) THEN BEGIN RetVal := FALSE; _Error := GETLASTERRORTEXT; END ELSE RetVal := TRUE;and this is sample
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> <Body> <ValidaXML_AIFM xmlns="urn:microsoft-dynamics-schemas/codeunit/AIFMValidation"> <_XMLToValidate>[string]</_XMLToValidate> <_Error>[string]</_Error> </ValidaXML_AIFM> </Body> </Envelope>In BC19 executing an action user send xml file.
trigger OnAction() var FileMgnt_: Codeunit "File Management"; TempBlob_: Codeunit "Temp Blob"; InStream_: InStream; Text50000_: Label 'Select file'; FileFilterTxt_: Label 'XML File (*.xml)|*.xml'; ExtFilterTxt_: Label 'xml'; Client_: HttpClient; Content_: HttpContent; Request_: HttpRequestMessage; RequestHdr_: httpheaders; ContentHdr_: HttpHeaders; ResponseMSg_: HttpResponseMessage; Response_: HttpResponseMessage; CnvTo64_: codeunit "Base64 Convert"; Parameters_: XmlDocument; Url: Text; AuthText_: text; ResTxt_: Text; XML_String: Text; ErrorCode_: Text; begin Url := 'http://myserver.domain:7257/NAV_WS/WS/CRONUS%20Italia%20S.p.A./Codeunit/AIFMValidation'; RequestHdr_.Clear(); AuthText_ := CnvTo64_.ToBase64('MyUsername:MyPassword'); Request_.GetHeaders(RequestHdr_); RequestHdr_.Add('Accept', 'application/xml'); RequestHdr_.Add('Authorization', StrSubstNo('NTLM %1', AuthText_)); ContentHdr_.Clear(); Content_.GetHeaders(ContentHdr_); ContentHdr_.Remove('Content-Type'); ContentHdr_.Add('Content-Type', 'text/xml'); Request_.Content(Content_); FileMgnt_.BLOBImportWithFilter(TempBlob_, Text50000_, '', FileFilterTxt_, ExtFilterTxt_); TempBlob_.CreateInStream(InStream_, TextEncoding::UTF8); instream_.ReadText(XML_String); Content_.writefrom(XML_String); Request_.SetRequestUri(Url); Request_.method('POST'); if Client_.Send(Request_, Response_) then begin if Response_.IsSuccessStatusCode() then begin Response_.Content.ReadAs(ResTxt_); if XmlDocument.ReadFrom(ResTxt_, XMLDoc2_) then begin ErrorCode_ := ''; end else begin ErrorCode_ := ResTxt_; Message(ErrorCode_); end end else begin ErrorCode_ := Response_.ReasonPhrase(); error(ErrorCode_); end; end else begin if Response_.Content.ReadAs(ResTxt_) then begin ErrorCode_ := ResTxt_; Error(ErrorCode_); end else begin ErrorCode_ := Response_.ReasonPhrase; Message(ErrorCode_); end end; end;Unfortunately, executing code returns BADREQUEST error.
Comments
In BC14, for the user, you need to activate the Web Service Access, and use Basic authentication with the user name and the Web Service Key.
Regardd
If the authentication works for you then ok , in the other hand change this code
Like that
Regards
Have you try to use Postman to see if the problem is with BC19 or with BC14 ?
I had to set in the header:
and in the body:
I miss to fill _XMLToValidate parameter to check.
Works
I tested it and your code with the modifications I said works,
Are you sure that the SOAPAction in Postman ended with AIFMValidationValidaXML_AIFM ?
Could you post again your code with the modifications ?
Regards.
this is my code now:
result of the call is:
The result is the same in both cases: What I am asking is how to indicate to the ws that we want to use one method rather than another?
I think the request is incorrect. It should look like this:
The SOAPAction should be only the name of the procedure that you are calling
And regarding the request, is an XML that you provided in this line
So get a correct XML file.
Regards.
Ok, that's the problem, you need to wrap this XML inside that tag, something like this:
And this new XML is the one to put in the Content.
Use this one:
Could you post the line with the SOAPAction ?
Regards
Well, the code, in my case with Basic Authentication, works with the tests that I have done.
Sorry, without see your environment, I'm out of ideas.
Regards
To understand the problem I'm trying to intercept the call with fiddler but I can't.
Every time I try fiddler it doesn't record anything ..
Fiddler is installed on the same server on which the BC service is.
Why?? If I use postman instead, it detects the call.
I also doing a different test: in a new project with target 'onPrem' I use the CU "SOAP Web Service Request Mgt." Also in this case it does not work.
This is code:
BlobImportWithFilter read this xml file that put in request: but server returns
Again fiddler does not record the call
Like I said before in the tests that I did it works, so without taking a look to your scenario I can help you.
Regards.