Hi All,
Below is solution for users who want to use SOAP API for OTRS.Below code is 
written in JavaScript and Using AJAX but can be used in any web language 
i.e.ASP,VB6,ASP.NET etc

1)Paste the code in notepad/wordpad and save it as HTML.
2)In Index.pl interface,sysconfig search for SOAP.Check the 2 check boxes and 
enter UID and PWD as "root"(without quotation).



Ravi Shankar.Ch


function OTRSTn()
{
 
SoapTest1='
                         'xmlns:xsd="http://www.w3.org/2001/XMLSchema"; ' +
                        
'soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>' +
                              '<soap:Body><Dispatch xmlns="/Core">' +
                               '<c-gensym4 
xsi:type="xsd:string">root</c-gensym4>' +
                                      '<c-gensym6 
xsi:type="xsd:string">root</c-gensym6>' +
                                                '<c-gensym8 
xsi:type="xsd:string">TicketObject</c-gensym8>' +
                                                '<c-gensym10 
xsi:type="xsd:string">TicketCreateNumber</c-gensym10>' +
'</Dispatch></soap:Body></soap:Envelope>'
 
return SoapTest1;
 
}

function OTRSTkt()
{
                                      
                         SoapTest2 = '
                         'xmlns:xsd="http://www.w3.org/2001/XMLSchema"; ' +
                        
'soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>' +
                              '<soap:Body><Dispatch xmlns="/Core">' +
                        '<c-gensym13 xsi:type="xsd:string">root</c-gensym13>' +
                        '<c-gensym15 xsi:type="xsd:string">root</c-gensym15>'+
                        '<c-gensym17 
xsi:type="xsd:string">TicketObject</c-gensym17>' +
                        '<c-gensym19 
xsi:type="xsd:string">TicketCreate</c-gensym19>' +
                        '<c-gensym21 
xsi:type="xsd:string">TN</c-gensym21><c-gensym23 xsi:type="xsd:long">'+ 
document.getElementById('tktid').value +'</c-gensym23>' +
                        '<c-gensym25 xsi:type="xsd:string">Title</c-gensym25>' +
                        '<c-gensym27 xsi:type="xsd:string">Test 
Ticket</c-gensym27>' +
                        '<c-gensym29 xsi:type="xsd:string">Queue</c-gensym29>' +
                        '<c-gensym31 
xsi:type="xsd:string">PostMaster</c-gensym31>' +
                        '<c-gensym33 xsi:type="xsd:string">Lock</c-gensym33>' +
                        '<c-gensym35 xsi:type="xsd:string">unlock</c-gensym35>' 
+
                        '<c-gensym37 
xsi:type="xsd:string">PriorityID</c-gensym37>' +
                        '<c-gensym39 xsi:type="xsd:int">2</c-gensym39>' +
                        '<c-gensym41 
xsi:type="xsd:string">State</c-gensym41><c-gensym43 
xsi:type="xsd:string">New</c-gensym43>' +
                        '<c-gensym45 
xsi:type="xsd:string">CustomerUser</c-gensym45><c-gensym47 
xsi:type="xsd:string">[email protected]</c-gensym47>' +
                        '<c-gensym49 
xsi:type="xsd:string">OwnerID</c-gensym49><c-gensym51 
xsi:type="xsd:int">1</c-gensym51>' +
                        '<c-gensym57 xsi:type="xsd:string">UserID</c-gensym57>' 
+
                        '<c-gensym59 xsi:type="xsd:int">1</c-gensym59>' +
                         '</Dispatch></soap:Body></soap:Envelope>'
return SoapTest2;
 
}
 
function OTRSTktArticle()
{
                   SoapTest3 ='
                   'xmlns:xsd="http://www.w3.org/2001/XMLSchema"; '+
                   
'soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";> ' +
                 '<soap:Body><Dispatch xmlns="/Core">' +
                   '<c-gensym62 
xsi:type="xsd:string">root</c-gensym62><c-gensym64 
xsi:type="xsd:string">root</c-gensym64> ' +
                   '<c-gensym66 
xsi:type="xsd:string">TicketObject</c-gensym66><c-gensym68 
xsi:type="xsd:string">ArticleSend</c-gensym68>' +
                   '<c-gensym70 xsi:type="xsd:string">TicketID</c-gensym70> '+
                   '<c-gensym72 xsi:type="xsd:int">'+ 
document.getElementById('tktNo').value +'</c-gensym72><c-gensym74 
xsi:type="xsd:string">ArticleType</c-gensym74> '+ 
                   '<c-gensym76 
xsi:type="xsd:string">email-external</c-gensym76> '+
                   '<c-gensym78 
xsi:type="xsd:string">SenderType</c-gensym78><c-gensym80 
xsi:type="xsd:string">agent</c-gensym80>'+
                   '<c-gensym82 
xsi:type="xsd:string">From</c-gensym82><c-gensym84 
xsi:type="xsd:string">[email protected]</c-gensym84>'+
                   '<c-gensym86 xsi:type="xsd:string">To</c-gensym86>'+
                   '<c-gensym88 
xsi:type="xsd:string">[email protected]</c-gensym88><c-gensym90 
xsi:type="xsd:string">Cc</c-gensym90>'+
                   '<c-gensym92 xsi:type="xsd:string" /><c-gensym94 
xsi:type="xsd:string">ReplyTo</c-gensym94>'+
                   '<c-gensym96 xsi:type="xsd:string" /><c-gensym98 
xsi:type="xsd:string">Subject</c-gensym98>'+
                   '<c-gensym100 xsi:type="xsd:string">USing 
SOAP</c-gensym100><c-gensym102 xsi:type="xsd:string">Body</c-gensym102>'+
                   '<c-gensym104 xsi:type="xsd:string">USing 
SOAP</c-gensym104><c-gensym106 xsi:type="xsd:string">MessageID</c-gensym106>'+
                   '<c-gensym108 xsi:type="xsd:string" />'+
                   '<c-gensym110 
xsi:type="xsd:string">Charset</c-gensym110><c-gensym112 
xsi:type="xsd:string">ISO-8859-15</c-gensym112>'+
                   '<c-gensym114 
xsi:type="xsd:string">HistoryType</c-gensym114>'+
                   '<c-gensym116 xsi:type="xsd:string">NewTicket</c-gensym116>'+
                   '<c-gensym118 
xsi:type="xsd:string">HistoryComment</c-gensym118>'+
                   '<c-gensym120 xsi:type="xsd:string">Ravi Created 
this</c-gensym120><c-gensym122 xsi:type="xsd:string">UserID</c-gensym122>'+
                   '<c-gensym124 xsi:type="xsd:int">1</c-gensym124>'+
                   '<c-gensym126 
xsi:type="xsd:string">NoAgentNotify</c-gensym126><c-gensym128 
xsi:type="xsd:int">0</c-gensym128>'+
                   '<c-gensym130 xsi:type="xsd:string">Type</c-gensym130>'+
                   '<c-gensym132 
xsi:type="xsd:string">text/plain</c-gensym132><c-gensym134 
xsi:type="xsd:string">Loop</c-gensym134>'+
                   '<c-gensym136 
xsi:type="xsd:int">0</c-gensym136></Dispatch></soap:Body></soap:Envelope>'
return SoapTest3;
 
 
}
 

 
function SendXml(id)
{
          
                   var url="http://x.x.x.x/otrs/rpc.pl";; //x.x.x.x is server 
name where otrs is residing.in local system is localhost
 
                   
                   var xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
                   xmlhttp2.open("POST",url,false);
                   xmlhttp2.setRequestHeader('Content-Type', 'text/xml');
                   xmlhttp2.setRequestHeader('SOAPAction', '/Core#Dispatch');
 
                   if(id==3)
                   {
                      var xmlArticle=OTRSTktArticle();
                      alert(xmlArticle);
                      xmlhttp2.send(xmlArticle)
 
                             if (xmlhttp2.Status==200)
                             { 
                                alert(xmlhttp2.responseText);
                                GetDetailsfromXML(xmlhttp2.responseText,3);
                             }
                             else
                             {
                                alert(xmlhttp2.responseText);     
                             }
                   }        
                   else if(id==2)
                   {
                      var xmlArticle=OTRSTkt();
                      alert(xmlArticle);
                      xmlhttp2.send(xmlArticle)
 
                             if (xmlhttp2.Status==200)
                             { 
                                alert(xmlhttp2.responseText);
                                GetDetailsfromXML(xmlhttp2.responseText,2);
                             }
                             else
                             {
                                alert(xmlhttp2.responseText);     
                             }
 
 
                   }
 
                   else if(id==4)
                   {
                      var xmlArticle=OTRSTktSearch();
                      alert(xmlArticle);
                      xmlhttp2.send(xmlArticle)
 
                             if (xmlhttp2.Status==200)
                             { 
                                alert(xmlhttp2.responseText);
                                GetDetailsfromXML(xmlhttp2.responseText,1);
                             }
                             else
                             {
                                alert(xmlhttp2.responseText);     
                             }
 
                             
                   }
                   else
                   {
                      var xmlArticle=OTRSTn();
                      alert(xmlArticle);
                      xmlhttp2.send(xmlArticle)
 
                             if (xmlhttp2.Status==200)
                             { 
                                alert(xmlhttp2.responseText);
                                GetDetailsfromXML(xmlhttp2.responseText,1);
                             }
                             else
                             {
                                alert(xmlhttp2.responseText);     
                             }
 
                             
                   }
 
                   
 
}
function GetDetailsfromXML(strXml,id)
          { 
                   alert(id+"%")
                   var ObjDoc
                   ObjDoc=new ActiveXObject("Microsoft.XMLDOM")
                   ObjDoc.loadXML(strXml)
                   var  nodelist
                   var CheckElement
                   
                   var str
                   str=new Array()
                   try
                   {
                             
                      if(id==3)
                      {     
                       nodelist=ObjDoc.getElementsByTagName('s-gensym12')
                         if (nodelist.length>0)        
                             {
                                       for (i = 0 ;i<=nodelist.length - 1;i++)
                                      {
                       
                                                CheckElement = nodelist[i]
                                                alert(CheckElement.text);    
                                                
document.getElementById('tktid').value=CheckElement.text
                             
                                      }        
                                      //For Applications in Host
 
                    
                             }
                             else
                             {
                             alert('Error in retrieving data from XML-3')
                             }
                      }
                      else if(id==2) 
                      {     
                             nodelist=ObjDoc.getElementsByTagName('s-gensym3')
                             if (nodelist.length>0)        
                              {
                                       for (i = 0 ;i<=nodelist.length - 1;i++)
                                      {
                       
                                                CheckElement = nodelist[i]
                                                alert(CheckElement.text);    
                                                
document.getElementById('tktNo').value=CheckElement.text
                             
                                      }        
                                      //For Applications in Host
 
                    
                              }
                             else
                             {
                             alert('Error in retrieving data from XML-2')
                             }
                      }
                      else
                      {
                              nodelist=ObjDoc.getElementsByTagName('s-gensym3')
                               if (nodelist.length>0)        
                               {
                                       for (i = 0 ;i<=nodelist.length - 1;i++)
                                      {
                       
                                                CheckElement = nodelist[i]
                                                alert(CheckElement.text);    
                                                
document.getElementById('tktid').value=CheckElement.text
                             
                                      }        
                                      //For Applications in Host
 
                                       
                              }
                             else
                             {
                             alert('Error in retrieving data from XML-1')
                             }
 
                      }
                             
                     
                   }//try
          catch(e)
          {
 
          }        
}
 
 
</script>
<input TYPE='button' NAME='Ajax' value='TicketNo' onClick='SendXml(1)'></input>
<input TYPE='button' NAME='Ajax2' value='TicketCreate' 
onClick='SendXml(2)'></input>
<input TYPE='button' NAME='Ajax3' value='ArticleCreate' 
onClick='SendXml(3)'></input>
<input TYPE='button' NAME='Ajax4' value='TktSearch' 
onClick='SendXml(4)'></input>
 
<input TYPE='text' NAME='tktid' id='tktid' ></input>
<input TYPE='text' NAME='tktid' id='tktNo' ></input>


      
---------------------------------------------------------------------
OTRS mailing list: otrs - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/otrs
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/otrs

NEW! ENTERPRISE SUBSCRIPTION - Get more information NOW!
http://www.otrs.com/en/support/enterprise-subscription/

Reply via email to