C# SOAP Client
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
C# SOAP Client
Hello,
I am using Visual Studio and C# to create a SOAP client for Integrity 10.2 web services.
Based on some questions here, I was able to make this working code: (actually fails due to a bug with jboss, but completes the request)
AttachmentRequest arg0 = new AttachmentRequest(); arg0.AttachmentName = "distributionowners.txt"; arg0.FieldName = "Attachments"; arg0.ItemId = "1234"; arg0.Username = "username"; arg0.Password = "password"; fetchAttachments fa = new fetchAttachments(); fa.arg0 = arg0; fetchAttachmentsResponse response = proxyClient.fetchAttachments(fa);
I just want to do getItem and createItem requests, but the format for getItem in the API seems different. The closest I was able to get was this:
Console.WriteLine(proxyClient.Endpoint.Address.Uri); getItemRequest req = new getItemRequest(); req.getItem.arg0.Username = "username"; //null reference req.getItem.arg0.Password = "password"; req.getItem.arg0.InputField = inputfields; req.getItem.arg0.ItemId = "1234"; getItem gi = new getItem(); gi.arg0 = req.getItem.arg0; getItemResponse responsegi = proxyClient.getItem(gi);
I'm not able to set the arg0 properties and it fails. How should I be doing this?
Solved! Go to Solution.
- Labels:
-
Requirements & Validation
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I got it to work using the following code:
using integrity;
//onclick event for vsta form button
public void CTRL12_5_Clicked(object sender, ClickedEventArgs e) { # region createhttpbinding BasicHttpBinding basicHttpbinding = new BasicHttpBinding(BasicHttpSecurityMode.None); basicHttpbinding.Name = "BasicHttpBinding_Integrity"; basicHttpbinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; basicHttpbinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; EndpointAddress endpointAddress = new EndpointAddress("http://servername:7001/webservices/10/2/Integrity/"); Integrity_10_2Client proxyClient = new Integrity_10_2Client(basicHttpbinding, endpointAddress); #endregion //set fields to pull string[] inputfields = { "Title", "Body", "User", "Department", "Priority", "Type" }; GetItemType git = new GetItemType(); git.InputField = inputfields; git.ItemId = itemid; git.Username = "username"; git.Password = "password"; git.transactionId = "x"; getItem gi = new getItem(); gi.arg0 = git; //from support.ptc.com Document-CS206732 getItemResponse gir = null; gir = proxyClient.getItem(gi); if (gir != null) { Item item = gir.@return; NullableShortString item0 = (NullableShortString)item.ItemField[0].Item; NullableString item1 = (NullableString)item.ItemField[1].Item; string item2 = ((string)item.ItemField[2].UserRecord[0].user.Item); NullableShortString item3 = (NullableShortString)item.ItemField[3].Item; NullableShortString item4 = (NullableShortString)item.ItemField[4].Item; string item5 = (string)item.ItemField[5].Item; //cast output as strings string Type = item5; string Title = (string)item0.Item; string Priority = (string)item4.Item; string Department = (string)item3.Item; string user = item2; string body = (string)item1.Item;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I got it to work using the following code:
using integrity;
//onclick event for vsta form button
public void CTRL12_5_Clicked(object sender, ClickedEventArgs e) { # region createhttpbinding BasicHttpBinding basicHttpbinding = new BasicHttpBinding(BasicHttpSecurityMode.None); basicHttpbinding.Name = "BasicHttpBinding_Integrity"; basicHttpbinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; basicHttpbinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; EndpointAddress endpointAddress = new EndpointAddress("http://servername:7001/webservices/10/2/Integrity/"); Integrity_10_2Client proxyClient = new Integrity_10_2Client(basicHttpbinding, endpointAddress); #endregion //set fields to pull string[] inputfields = { "Title", "Body", "User", "Department", "Priority", "Type" }; GetItemType git = new GetItemType(); git.InputField = inputfields; git.ItemId = itemid; git.Username = "username"; git.Password = "password"; git.transactionId = "x"; getItem gi = new getItem(); gi.arg0 = git; //from support.ptc.com Document-CS206732 getItemResponse gir = null; gir = proxyClient.getItem(gi); if (gir != null) { Item item = gir.@return; NullableShortString item0 = (NullableShortString)item.ItemField[0].Item; NullableString item1 = (NullableString)item.ItemField[1].Item; string item2 = ((string)item.ItemField[2].UserRecord[0].user.Item); NullableShortString item3 = (NullableShortString)item.ItemField[3].Item; NullableShortString item4 = (NullableShortString)item.ItemField[4].Item; string item5 = (string)item.ItemField[5].Item; //cast output as strings string Type = item5; string Title = (string)item0.Item; string Priority = (string)item4.Item; string Department = (string)item3.Item; string user = item2; string body = (string)item1.Item;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
can you suggest me how you got the integrity class for C#. did you created your self or you used some other library?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
It's generated by visual studio using the webservice definitions in integrity
1. In Visual Studio, go to Solution Explorer on the right side > expand and right-click References > add Service Reference (requires a project in .net 3.5 or later)
2. Fill in the address with http://servername:port/webservices/10/2/Integrity/?WSDL and click Go (where 10/2 are your Integrity version numbers)
3. Set the Namespace to "Integrity" (this is the class name)
4. Then make sure you include the library:
using [myProject].Integrity;
