06-14-2013 07:38 AM
I'm trying to use web services to retrieve attachments to change tickets. I do not appear to be succeeding. I'm writing code in .NET that makes use of web services. I can retrieve one or a list of changes without issue. I am setting the attachmentData and attachmentInfo fields to "true" in my request.
When the response is returned, the attachment field is null.
Is there anything else I have to do? Thanks. Here is a small code snippet:
changeRequest.attachmentData = true; changeRequest.attachmentInfo = true; changeRequest.ignoreEmptyElements = true;
Solved! Go to Solution.
06-15-2013 04:49 AM
I've wasted a lot of time to upload/download attachment using .net and WS. After that i asked HP support if its possible then they said we have a bug in HP SM and its not possible.
06-17-2013 06:19 AM
Thanks for your reply. I swear I saw threads where people said this was possible, but apparently it's not as possible as I thought. Here's what HP support has told me so far:
I believe those methods (attachmentData, etc) are for sending an attachment to SM, not for pulling from SM. I am in the process of checking for you, but I do not believe that OOB SM supports returning attachments on demand due to binary data handling and web service security risks. Some tailoring work in SM is necessary (you will need to write SM script libraries) per my last update to handle the wsdl request, and then the binary data retrieval from SM's SYSATTACHMENT table (eg; native getAttachment method) and insert it into the SOAP response packet.
This is typically done in JS, eg;
var f = new SCFile( 'cm3r' );
var rc = f.doSelect( 'number = "C10001"' );
var attachmentObj = f.getAttachments();
for ( var attachment in attachmentObj )
print("Attachment Name: "+ attachmentObj[ attachment ].name );
print("Attachment Value: "+ attachmentObj[ attachment ].stringValue );
print("Attachment Value Length: "+ attachmentObj[ attachment ].stringValue.length );
print("Attachment HREF: "+ attachmentObj[ attachment ].href );
print("Attachment Type: "+ attachmentObj[ attachment ].type);
str+= attachmentObj[ attachment ].stringValue ;
print("String Length: "+str.length);
I am not able to locate a complete script example of how this is attached to the returning web service response, but per my last update, I believe Professional Services have worked on projects like this in the past. They will need to be contacted for more detailed examples.
06-17-2013 09:11 AM
In this thread, the poster seems to be retrieving attachment data just using web services (http://h30499.www3.hp.com/t5/HP-Service-Manager-Se
In my .NET code, I'm doing what he's doing. Has something changed? Did this functionality break?
06-17-2013 11:18 AM
I made progress today in that I can now get HPSM to return file data. The code below is what I needed:
changeRequest.attachmentData = true; changeRequest.attachmentInfo = true; changeRequest.attachmentDataSpecified = true; changeRequest.attachmentInfoSpecified = true;
However, my .NET client throws an error when receiving the response. The error is long, but it starts like this:
"Client found response content type of 'multipart/related; type="text/xml"; boundary="----=_Part_50_6238894.1371488591938" ', but expected 'text/xml'."
I am continuing to research this now.
If anyone knows how to resolve the latest error, I'd really appreciate it.
09-19-2013 08:06 AM
"However, my .NET client throws an error when receiving the response. The error is long, but it starts like this:
"Client found response content type of 'multipart/related; type="text/xml"; boundary"
Hi lss123 , I have same error. Some people saw what cause of that is different between request and response objects(see post by Carlos http://social.msdn.microsoft.com/Forums/vstudio/en
Is You found a solution for working with attachments?
09-19-2013 08:20 AM
Yes, I did. I added messageEncloding="Mtom" to the web.config file as an attribute of the binding and that resolved this error. I did this a while ago so I don't know if I had to do anything else, but I definitely am retrieving attachments through web services, so it's possible. If you need more help just update this thread.
09-20-2013 02:30 AM
Good news :)
is web.config on client-side ? I put on my app.config :
but the error still reside.
Is you use a WEB-reference to "..sc62server/PWS/.." in your .net -project or use ServiceHost variable ?
09-20-2013 05:14 AM - edited 09-20-2013 05:16 AM
I don't know if anything in app.config will help; that's not what I did. Web.config is the configuration file in the root of any .NET project; when you deploy the project to IIS, web.config goes with it (so it's on the server side). When you add a Service Reference (steps outlined below), it'll add the configurations for it in web.config.
To set up the WSDL to HPSM, I used a Service Reference:
a) I right-clicked on Service References in the Solution Explorer
b) I chose "Add Service Reference"
c) I put in the address and the namespace and clicked the OK button.
I used this WSDL: http://<hpsmhost>:<portnumber>/SM/7/ws/<WSDL name>. I think this is important - you need to use the Service Reference, and you need to use /SM/7 - at least, I remember choosing these things specifically when I did this.
Do the steps above and see how far you get. If you get an error or get stuck, update the thread.
05-11-2014 06:53 AM
I'm facing the same issue.
I'm consuming the web service using add web reference, not as a service reference.
so I'm not able to configure the Encoding parameters, I tried to consume the web service as service reference, but I'm stuck in the authentication steps.
I'll appreciate if you can tell me how to authenticate the consuming of the service in order to try the encoding part.
05-12-2014 05:18 AM
When I create the HPSM web service client object, part of that object are credentials. I can show you the .NET code I used to add the credentials, and that's all I had to do as far as authentication.
myHpsmWebServiceClient ws = new myHpsmWebServiceClient(); ws.ClientCredentials.UserName.UserName = username; ws.ClientCredentials.UserName.Password = password;