Closed swaminathanmca closed 4 years ago
import { NgxSoapService, Client, ISoapMethodResponse } from 'ngx-soap'; import { from } from 'rxjs' constructor(private soap: NgxSoapService) { const promise = this.soap.createClient('serviceimplPort') from(promise).subscribe(client => this.client = client); } fileChange(event) { const fileList: FileList = event.target.files; this.fileName = fileList[0].name; this.selectedFile = event.target.files[0]; } onSubmit(document) { const token = wsse({ username: this.userName, password: this.password });
const body = { file: this.selectedFile };
'' + ''+this.userName+'</wsse:Username>' + '' + token.getPasswordDigest() + '</wsse:Password>' + token.getNonceBase64() + '</wsse:Nonce>' + token.getCreated() + '</wsu:Created></wsse:UsernameToken></wsse:Security>' + '</soapenv:Header>' + '' + ''+ ''+ document + '</wsdl:DocumentType>'+ ' '+ this.fileName+ '</wsdl:Subject>'+ ' '+ ' cid:'+ this.fileName+ '</wsdl:href>'+ ' </wsdl:PayloadName>'+ ' '+ ' ?</wsdl:href>'+ ' </wsdl:AttachmentFile>'+ ' </wsdl:SubmitMessageRequest>'+ ' </wsdl:MessageSubmission>'+ '</soapenv:Body>' + '</soapenv:Envelope>'; (this.client).Add(body).subscribe((res: ISoapMethodResponse) => console.log(res.result.AddResult)); }
MTOM support has been added, with #70 , thanks to @kverhoef.
import { NgxSoapService, Client, ISoapMethodResponse } from 'ngx-soap'; import { from } from 'rxjs' constructor(private soap: NgxSoapService) { const promise = this.soap.createClient('serviceimplPort') from(promise).subscribe(client => this.client = client); } fileChange(event) { const fileList: FileList = event.target.files; this.fileName = fileList[0].name; this.selectedFile = event.target.files[0]; } onSubmit(document) { const token = wsse({ username: this.userName, password: this.password });
'' +
''+this.userName+'</wsse:Username>' +
'' + token.getPasswordDigest() + '</wsse:Password>' + token.getNonceBase64() + '</wsse:Nonce>' + token.getCreated() + '</wsu:Created></wsse:UsernameToken></wsse:Security>' +
'</soapenv:Header>' +
'' +
''+
''+ document + '</wsdl:DocumentType>'+
' '+ this.fileName+ '</wsdl:Subject>'+
' '+
' cid:'+ this.fileName+ '</wsdl:href>'+
' </wsdl:PayloadName>'+
' '+
' ?</wsdl:href>'+
' </wsdl:AttachmentFile>'+
' </wsdl:SubmitMessageRequest>'+
' </wsdl:MessageSubmission>'+
'</soapenv:Body>' +
'</soapenv:Envelope>';
(this.client).Add(body).subscribe((res: ISoapMethodResponse) => console.log(res.result.AddResult));
}