Developing a Static wsdl with different Method in it

Paramahanns
Tera Expert

Hello All,

I have the static WSDL defined. Also I have the scripted webservice defined. Can some one give a example where some body developed integration using the scripted webservices and Static wsdl.

I created one but I am not sure I am doing it correctly.

I created a execute scripted web services. And in the static added more methods like insert, Update, Delete. But when I post a transaction the response is not   received. Also I am doing a mistake.

Can some one reply back with an example..

Introduction to Static WSDLs in ServiceNow | John Andersen

I looked into this got few of the things.. But since I am trying this new I need you help to get this completed.

Please respond.

REgards

Param

1 ACCEPTED SOLUTION

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

15 REPLIES 15

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


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.