Attachment and Webservice (3880 Views)
Reply
Regular Advisor
Chubaka
Posts: 124
Registered: ‎02-08-2010
Message 1 of 18 (3,880 Views)
Accepted Solution

Attachment and Webservice

Hi experts,

 

Working on SM7.02.

 

How could I get back information about attachment with the "RetrieveIncident" webservice ? (trying with SoapUI or with my website). I do not know JS.... :-(

 

Is it possible to get the attachment back using webservice out of SM7 ?

 

Thanks.

Honored Contributor
Abhijit K
Posts: 900
Registered: ‎10-14-2010
Message 2 of 18 (3,875 Views)

Re: Attachment and Webservice

Hi chubaka,

 

Would you like to retrieve attachments from incidents tickets?

 

I guess earlier froum discuss this thing.

 

 

Thanks and regards,

abhijit khewale

Regular Advisor
Chubaka
Posts: 124
Registered: ‎02-08-2010
Message 3 of 18 (3,863 Views)

Re: Attachment and Webservice

yes indeed,

 

but none about how I can get the data back outside SM7.

 

For example, I try to get the data from SoapUI. I put the value "true" to attachmentInfo and attachmentData in the RetrieveIncidentRequest.

I've got his in response :

               <attachments>
                  <cmn:attachment href="cid:id4e8dbbec002d704003656d88" len="2870" name="JS_Attach.txt" type="text/plain"/>
               </attachments>


Now, could you explain me which webservices should be invoke to get the data back that I can read it ?

What is the syntax for this ?

 

Thanks for your help

 

Honored Contributor
Abhijit K
Posts: 900
Registered: ‎10-14-2010
Message 4 of 18 (3,856 Views)

Re: Attachment and Webservice

Hi C,

 

You  are trying to get attachments from IncidentManagement wsdl thats is not possible because attachments are stored in file SYSATTACHMENTS.

 

Incidents stores only reference id to that attachments.

 

re,

abhijit

Regular Advisor
Chubaka
Posts: 124
Registered: ‎02-08-2010
Message 5 of 18 (3,853 Views)

Re: Attachment and Webservice

[ Edited ]

HI,

 

Thanks for your answer.

 

I understood that I could not get data from this wsdl but only information about the attachment.

 

What I try to ask is ; do I need to invoke another wsdl ? If yes, which one ? And if it is not present, should I build a custom one which can allow me to get the data back ? And what will be the parameters for it ?

 

I try to make a new one named Attachments on SYSATTACHMENT table.

 

I have now a new wsdl that I added in SoapUI. Even in that case, I can not get data (or binaries) of the attachment.

I'm a bit lost now and I do not know what to do to get these files attached to an incident.

 

Thanks all for your help

 

Regular Advisor
Chubaka
Posts: 124
Registered: ‎02-08-2010
Message 6 of 18 (3,837 Views)

Re: Attachment and Webservice

anyone ?

 

 

Regular Advisor
Chubaka
Posts: 124
Registered: ‎02-08-2010
Message 7 of 18 (3,804 Views)

Re: Attachment and Webservice

Solved

Regular Advisor
Chubaka
Posts: 124
Registered: ‎02-08-2010
Message 8 of 18 (3,798 Views)

Re: Attachment and Webservice

Here is the solution :

 

Solution in SoapUI for creating :

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pws="http://servicecenter.peregrine.com/PWS" xmlns:com="http://servicecenter.peregrine.com/PWS/Common">
   <soapenv:Header/>
   <soapenv:Body>
      <pws:CreateIncidentRequest attachmentInfo="true" attachmentData="true" ignoreEmptyElements="true">
         <pws:model>
            <pws:keys>
               <pws:IncidentID></pws:IncidentID>
            </pws:keys>
            <pws:instance>
               <pws:IncidentID></pws:IncidentID>
               <pws:severity>3</pws:severity>
               <pws:InitialImpact>3</pws:InitialImpact>
               <pws:Category>International Applications</pws:Category>
               <pws:PrimaryAssignmentGroup>Administration</pws:PrimaryAssignmentGroup>
               <pws:IncidentDescription>
                  <pws:IncidentDescription>Test </pws:IncidentDescription>
               </pws:IncidentDescription>
               <pws:AssigneeName>YOURASSIGNEENAME</pws:AssigneeName>
               <pws:Contact>YOURCONTACTNAME</pws:Contact>
               <pws:BriefDescription>Test Création</pws:BriefDescription>
               <pws:Subcategory>Service Manager</pws:Subcategory>
               <pws:ProductType>User Administration</pws:ProductType>
               <pws:ProblemType>N/A</pws:ProblemType>
        <pws:attachments>
                  <com:attachment href="&lt;UserData.txt>" contentId="" action="add" name="UserData.txt" type="" len="" charset="" attachmentType=""/>
               </pws:attachments>
            </pws:instance>
            <pws:messages>
               <com:message></com:message>
            </pws:messages>
         </pws:model>
      </pws:CreateIncidentRequest>
   </soapenv:Body>
</soapenv:Envelope>

 

As you can see, careful to the attribut "com:attachment" : 

The href should start with &lt; because it the non coded html tag (Ex : href="&lt;UserData.txt>") and finish by the usual tag ">"

 

 

Hope this help someone one day.

 

Best regards

Advisor
madhavaks
Posts: 24
Registered: ‎07-06-2011
Message 9 of 18 (3,750 Views)

Re: Attachment and Webservice

Hello Chubaka,

 

The solution is to insert attachment to a Incident via webservice. Is there any way to get the attachement from Service manager using webservice (or using Connect IT).

 

Thanks & Regards,

Madhava

Regular Advisor
Chubaka
Posts: 124
Registered: ‎02-08-2010
Message 10 of 18 (3,746 Views)

Re: Attachment and Webservice

Hi

 

 

 

 

 

 

Honored Contributor
Abhijit K
Posts: 900
Registered: ‎10-14-2010
Message 11 of 18 (3,737 Views)

Re: Attachment and Webservice

Hi Chubaka,

Thanks for sharing this.

Regards,
abhijit k
Advisor
madhavaks
Posts: 24
Registered: ‎07-06-2011
Message 12 of 18 (3,732 Views)

Re: Attachment and Webservice

Hello Chubaka,

 

Thanks for your help.

 

Thanks & Regards,

Madhava

Occasional Advisor
SwatiShah
Posts: 8
Registered: ‎03-28-2012
Message 13 of 18 (3,157 Views)

Re: Attachment and Webservice

Hi

  I am trying to insert the attachment in Create Incident.. where does attachment sit in file system to insert? And what is content-type of SOAP ENV? I tried full path in href too but did not work.

Honored Contributor
Abhijit K
Posts: 900
Registered: ‎10-14-2010
Message 14 of 18 (3,140 Views)

Re: Attachment and Webservice

Hi Swati,

 

Which client you are using?

 

Regards,

Abhijit K

Occasional Advisor
SwatiShah
Posts: 8
Registered: ‎03-28-2012
Message 15 of 18 (3,133 Views)

Re: Attachment and Webservice

Hi Abhijeet

   I am trying this via HPOO. Sending an SOAP request to HPSM to create incident with attachments. I recieve it fine as MTOM message with parts and want to send same thing . I have a file on HPOO server and want to attach it with indcident. Will i have to create my own custom functionality to do the same?

Occasional Advisor
SwatiShah
Posts: 8
Registered: ‎03-28-2012
Message 16 of 18 (3,129 Views)

Re: Attachment and Webservice

Hi

  I created a mulipart SOAP request using (Java API) to sent to HPSM. It was success but no attachments were attached. Log files showed the following

 E Error -1 trying to update attachment for cm3r C047XXXXX

 

cm3r is our change manaagement table

Advisor
UniMacStar
Posts: 25
Registered: ‎12-14-2011
Message 17 of 18 (1,848 Views)

Re: Attachment and Webservice

Hi,

 

I am writing this after so much research on handling attachment with third party web service.

I have written below code in order to send attachment data to third party web service.

//Calling Incident ID by using global variable
var HPSMIncident = system.vars.$G_IncId;
//Fetching probsummary record for Incident Id
var IncidentFile = new SCFile( "probsummary" );
var findIncident = IncidentFile.doSelect( "number#\""+ HPSMIncident + "\"" );
var updatedby=IncidentFile.updated_by;
var clientIncidentId=IncidentFile.si_serv_incident_id;
var assignment=IncidentFile.assignment;
var IncidentSIDBID = IncidentFile.si_initiator_incident;
var SIBUS = IncidentFile.si_bus;
var j = "0";
var i = "0";
if (clientIncidentId!=null || assignment == "advantage" && updatedby!="siuser" )
{

var JBOSSCreateHistoryLogServSvc = new system.library.HTTPHistoryRecordServService.HTTPHistoryRecordServService();
var JBOSSCreateHistoryLogServReq = new system.library.HTTPHistoryRecordServService.createHistoryLog();
var JBOSSCreateHistoryLogServResp = new system.library.HTTPHistoryRecordServService.createHistoryLogResponse();
var IBMCreateHistoryLogServSvc = new system.library.MB_ProcessHistoryLog_MessageSetSOAP_HTTP_Service.MB_ProcessHistoryLog_MessageSetSOAP_HTTP_Service();
var IBMCreateHistoryLogServReq = new system.library.MB_ProcessHistoryLog_MessageSetSOAP_HTTP_Service.processHistoryLog();
var IBMCreateHistoryLogServResp = new system.library.MB_ProcessHistoryLog_MessageSetSOAP_HTTP_Service.processHistoryLogResponse();
var attach;
JBOSSCreateHistoryLogServReq.attachmentInfo = true;
JBOSSCreateHistoryLogServReq.attachmentData = true;
IBMCreateHistoryLogServReq.attachmentInfo = true;
IBMCreateHistoryLogServReq.attachmentData = true;
var ActivityQuery;
var ActivityTimeStamp;
var ActivityNumber;
var IncidentNumber;
var ActivityType;
var ActivityDesc;
var attachdata;
var attachname;
var SIsysmodtime;
function findLastActivity( query )
{
var ActivityFile = new SCFile( "activity" );
var findActivity = ActivityFile.doSelect( "number#\""+ query + "\"");
if ( findActivity == RC_SUCCESS )
{
ActivityNumber = ActivityFile.thenumber;
ActivityType = ActivityFile.type;
ActivityDesc = ActivityFile.description;
ActivityDesc = ActivityDesc.getText();
ActivityDesc = ActivityDesc.replace(/[""{}]/g, "");
IncidentNumber = ActivityFile.number;
return ActivityFile
}
else
{
print( "Could not find Activitys starting with " + query + ". " + RCtoString( findActivity ) );
return null
}
}

var ActivityQuery = system.vars.$G_IncId;
//calling Activity Table function
findLastActivity( ActivityQuery );
print("ActivityType"+ActivityType);
if ( ActivityType == "1" || ActivityType == "-1" || ActivityType == "0" || ActivityType == "01" || ActivityType == "00" || ActivityType == "External Update" || ActivityType == "Closed" || ActivityType == "Resolved" || ActivityType == "Open" || ActivityType == "Assignment" || ActivityType == "Reassignment" || ActivityType == "Status Change" )
{
print("This is not manual activity update");
return null
}
else
{
print("SUCCESS");
//==================Attachments Start"
var SiAttachFile = new SCFile("SYSATTACHMENTS");
var findIncidentquery="topic=\""+IncidentNumber+"\"";
var rc = SiAttachFile.doSelect(findIncidentquery);
if ( rc == RC_SUCCESS )
{
var x = new SCRecordList( 'SYSATTACHMENTS', new QueryCond('topic',LIKE, IncidentNumber));
print("Total record in the list: " + x.getCount());
//for (i in x )
//print(x[i].sysmodtime + " is the " + x.getPosition() + " record in the record list." );
for (i in x )
{
SIsysmoduser = x[i].sysmoduser;
var SIAttachAction = x[i].SIAttachAction;
print("SIAttachAction::"+SIAttachAction);
if ( SIsysmoduser != "siuser" && SIAttachAction == null )
{
print("j in loop"+j);
attachdata = x[i].filename;
attachname = x[i].data;
attachname = base64Encode(attachname);
print("attachname"+attachname);
//attachname = x[i].data;
//print("attachment of "+i+"record \n"+attachdata+"\n"+attachname);
if( SIBUS == "JBOSS_SI" )
{
if ( j == "0" )
{
print("attachment of "+i+"record \n"+attachdata+"\n"+attachname);
JBOSSCreateHistoryLogServReq.attachment1.attachmentName.setValue(attachdata);
JBOSSCreateHistoryLogServReq.attachment1.attachmentData.setValue(attachname);
x[i].SIAttachAction = 1;
print("x[i].SIAttachAction"+x[i].SIAttachAction);
x[i].doSave();
j++;
}
else if ( j == "1" )
{
print("attachment of "+i+"record \n"+attachdata+"\n"+attachname);
JBOSSCreateHistoryLogServReq.attachment2.attachmentName.setValue(attachdata);
JBOSSCreateHistoryLogServReq.attachment2.attachmentData.setValue(attachname);
x[i].SIAttachAction = 1;
print("x[i].SIAttachAction"+x[i].SIAttachAction);
x[i].doSave();
j++;
}
else if ( j == "2" )
{
print("attachment of "+i+"record \n"+attachdata+"\n"+attachname);
JBOSSCreateHistoryLogServReq.attachment3.attachmentName.setValue(attachdata);
JBOSSCreateHistoryLogServReq.attachment3.attachmentData.setValue(attachname);
x[i].SIAttachAction = 1;
print("x[i].SIAttachAction"+x[i].SIAttachAction);
x[i].doSave();
j++;
}


}
else if (SIBUS == "IBM_SI" )
{
if ( j == "0" )
{
print(j+"attachment of "+i+"record \n"+attachdata+"\n"+attachname);
IBMCreateHistoryLogServReq.attachment1.attachmentName.setValue(attachdata);
IBMCreateHistoryLogServReq.attachment1.attachmentData.setValue(attachname);
x[i].SIAttachAction = 1;
print("x[i].SIAttachAction"+x[i].SIAttachAction);
x[i].doSave();
j++
}
else if ( j == "1" )
{
print(j+"attachment of "+i+"record \n"+attachdata+"\n"+attachname);
IBMCreateHistoryLogServReq.attachment2.attachmentName.setValue(attachdata);
IBMCreateHistoryLogServReq.attachment2.attachmentData.setValue(attachname);
x[i].SIAttachAction = 1;
print("x[i].SIAttachAction"+x[i].SIAttachAction);
x[i].doSave();
j++;
}
else if ( j == "2" )
{
print(j+"attachment of "+i+"record \n"+attachdata+"\n"+attachname);
IBMCreateHistoryLogServReq.attachment3.attachmentName.setValue(attachdata);
IBMCreateHistoryLogServReq.attachment3.attachmentData.setValue(attachname);
x[i].SIAttachAction = 1;
print("x[i].SIAttachAction"+x[i].SIAttachAction);
x[i].doSave();
j++;
}
}
}


}

}
//SI Bus field mapping
if ( SIBUS == "JBOSS_SI" )
{
JBOSSCreateHistoryLogServReq.actionType.setValue("CREATE");
//print("Mapping:\n IncidentNumber:"+IncidentNumber+"\n IncidentSIDBID"+IncidentSIDBID+"\n ActivityNumber"+ActivityNumber+"\n ActivityDesc"+ActivityDesc);
JBOSSCreateHistoryLogServReq.incidentUniqueIdentifierId.setValue(IncidentNumber);
JBOSSCreateHistoryLogServReq.siUniqueID.setValue(IncidentSIDBID);
JBOSSCreateHistoryLogServReq.siUniqueTenantName.setValue("advantage");
JBOSSCreateHistoryLogServReq.initiatorHistoryLogId.setValue(ActivityNumber);
JBOSSCreateHistoryLogServReq.logType.setValue("External Update");
JBOSSCreateHistoryLogServReq.summary.setValue(ActivityDesc);
JBOSSCreateHistoryLogServReq.description.setValue(ActivityDesc);
}
else if ( SIBUS == "IBM_SI" )
{
IBMCreateHistoryLogServReq.actionType.setValue("CREATE");
//print("Mapping:\n IncidentNumber:"+IncidentNumber+"\n IncidentSIDBID"+IncidentSIDBID+"\n ActivityNumber"+ActivityNumber+"\n ActivityDesc"+ActivityDesc);
IBMCreateHistoryLogServReq.incidentUniqueIdentifierID.setValue(IncidentNumber);
IBMCreateHistoryLogServReq.SIIncidentUniqueID.setValue(IncidentSIDBID);
IBMCreateHistoryLogServReq.siUniqueTenentName.setValue("advantage");
IBMCreateHistoryLogServReq.initiatorHistoryLogId.setValue(ActivityNumber);
IBMCreateHistoryLogServReq.logType.setValue("External Update");
IBMCreateHistoryLogServReq.summary.setValue(ActivityDesc);
IBMCreateHistoryLogServReq.description.setValue(ActivityDesc);
}
else
return false

try
{
if ( SIBUS == "JBOSS_SI" )
{
var JBOSSCreateHistoryLogServResp = JBOSSCreateHistoryLogServSvc.invoke(JBOSSCreateHistoryLogServReq);
if(JBOSSCreateHistoryLogServResp.isFault())
{
throw("SOAP Fault"+JBOSSCreateHistoryLogServResp.faultstring.getValue());
}
print(JBOSSCreateHistoryLogServResp.incidentUniqueIdentifierId.getValue());
print(JBOSSCreateHistoryLogServResp.siUniqueHistoryLogId.getValue());
print(JBOSSCreateHistoryLogServResp.transactionStatus.getValue());
print(JBOSSCreateHistoryLogServResp.transactionStatusDesciption.getValue());
return JBOSSCreateHistoryLogServResp;
}
else if ( SIBUS == "IBM_SI" )
{
var IBMCreateHistoryLogServResp = IBMCreateHistoryLogServSvc.invoke(IBMCreateHistoryLogServReq);
if(IBMCreateHistoryLogServResp.isFault())
{
throw("SOAP Fault"+IBMCreateHistoryLogServResp.faultstring.getValue());
}
print("SUCCESS");
print(IBMCreateHistoryLogServResp.incidentUniqueIdentifierID.getValue());
print(IBMCreateHistoryLogServResp.SIHistoryLogId.getValue());
print(IBMCreateHistoryLogServResp.transactionStatusCode.getValue());
print(IBMCreateHistoryLogServResp.transactionStatusDesc.getValue());
return IBMCreateHistoryLogServResp;
}
}

catch(err)
{
print("Error!"+err);
return("Error!"+err);
}
}

}

 

By using above, could able to send only .txt file but not other formats. Even HP clearly stated that hadnt have any standard way to consume attachments for all the formats like .txt, .jpeg, .pdf and .xls.

 

If anybody has idea using java script, how to consume attachments. Please share with us.

 

Really it would be great helpful. Kudos added.

 

 

Frequent Advisor
abhin88
Posts: 104
Registered: ‎01-07-2013
Message 18 of 18 (1,575 Views)

Re: Attachment and Webservice

Hi All

 

I was wondering if we can do the same with RESTful API ? 

 

Abhinav

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.