Forum Discussion

yvijayd's avatar
yvijayd
Occasional Contributor
13 years ago

SoapUI API for Authentication

Hi all,
Have a scenario to authenticate(passing: Domain, Username, Password) secured wsdl through API than the SoapUI tool. Getting "Unauthorized error" for below code.

WsdlProject SoapUIProject = new WsdlProject();
WsdlInterface SoapUIInterface = WsdlInterfaceFactory.importWsdl(SoapUIProject, null, true)[0];
WsdlOperation SoapUIOperation = (WsdlOperation) SoapUIInterface.getOperationByName(strWebMethodName);
WsdlRequest SoapUIRequest = SoapUIOperation.addNewRequest("Myrequest");
SoapUIRequest.setRequestContent(SoapUIOperation.createRequest(true));
if (strArguments.length() > 0) {
String strRequestXML = SoapUIRequest.getRequestContent();
String[] strArgs = strArguments.split(",");
for (int i = 0; i < strArgs.length; i++) {
String[] strArg = strArgs.split("=");
strRequestXML = strRequestXML.replace(strArg[0] + ">?",strArg[0] + ">" + strArg[1]);
}
SoapUIRequest.setRequestContent(strRequestXML);
}
WsdlSubmit SoapUISubmit = (WsdlSubmit) SoapUIRequest.submit(new WsdlSubmitContext(SoapUIRequest), false);

Please suggest me to resolve this issue.
Thanks in advance.

Regards,
Vijay D

11 Replies

  • nmrao's avatar
    nmrao
    Community Hero
    Dont have clear cut steps. However, it should be like set required properties for the out going request before sending like user name, password, password type and domain if your service operation needs.