Any help on this please.



Regards


Param


The input and output parameters are used when generating the WSDL. As you are using a static WSDL they will be ignored. I believe the only way will be to parse the XML request manually via a script.



See Creating a Static WSDL - ServiceNow Wiki - the Script include section has an example of reading a request and posting a response.



If you don't need a static WSDL you can specify the input and output parameters and reference them with 'request.parameter' and 'response.parameter'


Thanks. I just managed to send the response in the Advanced Scripting of the Scripted web services section and I got the response.



Regards


Param


View solution in original post

Great job Param.   You should share your script on here so that there is a working example for the future .



Nicely done, John


Hi John,



var vProcessor = new FakeInsertMethod(soapRequestXML);


var responseElement = vProcessor.process();
if (responseElement != null) {
    response.soapResponseElement = responseElement;
} else {
    response.soapResponseElement = vProcessor.generateSoapFault("unknown error");
}


var FakeInsertMethod= Class.create();
FakeInsertMethod= {
      initialize : function(requestXML) {
  this.xmlutil = GlideXMLUtil;
    this.fSoapDoc = new XMLDocument(requestXML);
      },

process : function() {
var soapBody = this.fSoapDoc.getNode("/Envelope/Body");
var funcNode = this.xmlutil.getFirstChildElement(soapBody);
var nodeName = this.xmlutil.getNodeNameNS(funcNode);
if (nodeName == "insert") {
  return this.insertRec(funcNode);
}

    return this.generateSoapFault("un-supported API call: " + nodeName);
},

insertRec : function (funcNode) {
          var r = new XMLDocument("<insertResponse xmlns='https://www.service-now.com/wsdlname'/>");
          var fieldname1= this.fSoapDoc.getElementValueByTagName('fieldname1');
          var fieldname2= this.fSoapDoc.getElementValueByTagName('fieldname2');
    var gr = new GlideRecord("Tablename");
          gr.addQuery('name', fieldname1);
    gr.query();
    if(gr.next())
{
gr.initialize();
  gr.fieldname1 = fieldname1;
  gr.fieldname2 = fieldname2;
  var cisysid = gr.insert();
    r.createElement("message", "CI successfully inserted with sys id : "+fieldname1);
}
return r.getDocumentElement();
  },


generateSoapFault: function (str) {
        var f = "<SOAP-ENV:Fault>" +
                            "<faultcode xsi:type='xsd:string'>SOAP-ENV:ucmdbsnow</faultcode>" +
                            "<faultstring xsi:type='xsd:string'>" + str +
                            "</faultstring>" +
                        "</SOAP-ENV:Fault>";
        var s = new XMLDocument(f);
        return s.getDocumentElement();
  },


};



Here is the code I came up with.