How to consume a referenced webservice in visual studio 2012 - vb.net

I have added a reference of a soap webservice in my visual studio 2012. Working for the first time with is a little bit hard because it gave an error and I don't know how to resolve it. Any hints? Below is my code:
Dim obj() As MobileApp.ClaimsDetails
Dim respClaimsDetails As MobileApp.BAMobileAppSoap
Dim a As New MobileApp.MVGetClaimsDetailsAllRequest
a.strVisaID = 123
Dim b As New MobileApp.MVGetClaimsDetailsAllResponse
b = respClaimsDetails.MVGetClaimsDetailsAll(a)
obj = b.MVGetClaimsDetailsAllResult
MobileApp is the name of my webservice. The exception thrown is a null reference in respClaimsDetails.MVGetClaimsDetailsAll(a).
I know that MobileApp.BAMobileAppSoap is an interface that needs a Concrete Implementation to complete my work, but I have at least 50 interfaces, I cannot concrete them all... I am sure there is another way to call webservice and resolve this issue ... any help, any links or documentation concerning added webservices in visual studio 2012 are appreciated.
Regards.

OK finally I could solve it :
Instad of using an interface there a class for client that takes a parameter "BAMobileAppSoap" which is the enpoint name in web.config, and then I could call my methods easily:
Dim respClaimsDetails As New MobileApp.BAMobileAppSoapClient("BAMobileAppSoap")
Dim res = respClaimsDetails.MVGetClaimsDetailsAll(claimNum)

Related

Determine Documentum host name when using Documentum.Interop.DFC C# assembly

I'm working on some rather old C# code that uses Documentum DFC (Documentum.Interop.DFC.dll 6.5.0.18). The Documentum server settings are stored within the dfc.properties file stored on my local machine, for example:
dfc.docbroker.host[0]=xyzserver.xyzdomain.net
dfc.docbroker.port[0]=5432
I would like to be able to determine, and write to a log file, the Documentum "docbroker" host and port number whenever the Documentum COM objects are instantiated. Here's what I have so far:
DfClientX xClient = new DfClientXClass(); // <=== This xClient should have the host in there somewhere... right?
IDfLoginInfo login = xClient.getLoginInfo();
login.setUser( localUserName );
login.setPassword( localUserPassword );
xClient is an interface of type DfClientX, it is instantiated as a COM object.
Looping through all of the properties of the object suggested by this post looks promising.
I've searched on the Documentum boards with no luck so far. I realize this question will be difficult to answer without having access to the Documentum software, but it seems like it should be a rather simple task... perhaps someone with more general COM knowledge can help out?
Thanks in advance!
So after checking out the object in the Visual Studio watch window (not within the "tooltip" watch), I was able to use Intellisense to examine the properties available to the COM object and its properties. Here is how I am now able to determine the host name:
DfClientX xClient = new DfClientXClass();
IDfClient client = xClient.getLocalClient();
const string HOST_ATTRIBUTE = "dfc.docbroker.host";
var hostSetting = xClient.getLocalClient().getClientConfig().getString( HOST_ATTRIBUTE );
Logging.WriteLog( TraceEventType.Verbose, "*** {0} = {1}", HOST_ATTRIBUTE, hostSetting.ToString() );
Maybe this will help somebody else in the future.

Consuming WCF return value of List(Of String) in WinForms

I've just started to get rid of Web Services and implement WCF instead. But once I tried to add the following method with a List(Of String) return value, my WCF ServiceReference - which was added successfully - had became unreadable in my WinForms client application code. i.e. It was not defined.
The scenario is pretty simple:
I am creating an OperationContract named ServerMessages with a list of string return value.
This is the interface:
<ServiceContract()>
Public Interface ICommunicationHandler
<OperationContract()>
Function ServerMessages() As List(Of String)
End Interface
And there is the implementation class:
Public Class CommunicationHandler
Implements ICommunicationHandler
Public Function ServerMessages() As List(Of String) _
Implements ICommunicationHandler.ServerMessages
Dim messages As New List(Of String)
messages.Add("First Message")
messages.Add("Second Message")
Return messages
End Function
End Class
There is my client application code:
Dim locServ As New LocalReference.CommunicationHandlerClient
TextBox1.Text += "First Server Messages:" & vbLf & locaServ.ServerMessages(0)
I've tried removing the service reference from the project and re-adding it, but this doesn't solved the problem. On the other hand, removing that specific method ServerMessages() makes the ServiceReference available again in my code. I've even tried to define the type List(Of String) in the Service Interface by adding this attribute:
<ServiceKnownType(GetType(List(Of String)), ServiceContract()>
but nothing had changed.
EDIT
I've noticed this warning in the client application Error window:
Warning 2 Custom tool warning: Cannot import wsdl:port Detail: There
was an error importing a wsdl:binding that the wsdl:port is dependent
on. XPath to wsdl:binding:
//wsdl:definitions[#targetNamespace='http://tempuri.org/']/wsdl:binding[#name='BasicHttpBinding_ICommunicationHandler']
XPath to Error Source:
//wsdl:definitions[#targetNamespace='http://tempuri.org/']/wsdl:service[#name='CommunicationHandler']/wsdl:port[#name='BasicHttpBinding_ICommunicationHandler'] D:\WCTApp\Service
References\LocalReference\Reference.svcmap
Thanks in advance.
My problem was solved by unchecking the [Reuse types in referenced assemblies] in the WCF ServiceReference configuration of my client application. Thanks Steve for letting me having another check on it.
The problem - in this case - was that I've added some references in the service (Google Drive references) which was not defined in my application and therefore causing the ServiceReference not to read the service appropriately. Since I decided not to use these references, I should had eliminated them both from my client application as well as the WCF Service. Now that I stopped using these references in my client application, everything worked as it is supposed to be.
This was my mistake but maybe someone else will fall into the exact same issue and find this situation helpful.

Active Directory - Create Computer into container with 'Everyone' ACL

I am currently still beginning to understand Active Directory, I am able to add domain groups into local administrator group but I would like to understand how to approach this : I need to create a computer into the right container in my domain, which I understand how to achieve this, but I do not understand how I can be able to achieve the 'Everyone' ACL whenever I create a new computer in the domain by code.
Note :
1. I am not asking for code, I want to understand how to achieve this so any guidance/articles will be greatly appreciated as I just seem to be unable to find any articles related to my case.
2. I am using Visual Basic to achieve this in Visual Studio 2008.
Thanks for any replies in advance, looking forward to learning this. :)
Edit 1 : Found several ways that might achieve this : powershell or group policy
I found an alternative for VB.net
The following Visual Basic example shows how to read a security descriptor on an object.
Imports ActiveDS
Imports System.Collections
Dim ent As New DirectoryEntry("LDAP://CN=ComputerName,OU=container,DC=domain,DC=com")
Dim sd As SecurityDescriptor = CType(ent.Properties("ntSecurityDescriptor").Value,SecurityDescriptor)
Dim acl As AccessControlList = CType(sd.DiscretionaryAcl, AccessControlList)
Dim ace As AccessControlEntry
For Each ace In CType(acl, IEnumerable)
Console.WriteLine("Trustee: {0}", ace.Trustee)
Console.WriteLine("AccessMask: {0}", ace.AccessMask)
Console.WriteLine("Access Type: {0}", ace.AceType)
Next ace
The following Visual Basic example shows you how to write a security descriptor to an object.
Import ActiveDS
Dim usr As New DirectoryEntry("LDAP://CN=ComputerName,OU=container,DC=domain,DC=com")
Dim newAce = New AccessControlEntryClass()
Dim usrSD As SecurityDescriptor = CType(usr.Properties("ntSecurityDescriptor").Value, SecurityDescriptor)
Dim usrAcl As AccessControlList = CType(usrSD.DiscretionaryAcl, AccessControlList)
newAce.Trustee = "Anything"
newAce.AccessMask = - 1
newAce.AceType = 0
usrAcl.AddAce(newAce)
usrSD.DiscretionaryAcl = usrAcl
usr.Properties("ntSecurityDescriptor").Value = usrSD
usr.CommitChanges()
You have to add reference into the solution. Add Reference --> COM --> Active DS Type Library

Unable to resolve symbol 'ExecutionInfo'

I'm getting this error when trying to use ReportingService2010:
Unable to resolve symbol 'ExecutionInfo'
ExecutionInfo and ExecutionHeader worked in ReportingService2005. I'm using Visual Studio 2010, VB.Net, and ReportingServices2010. I can connect to the server and do things like rs.ListChildren.
Any Ideas?
I found the answer to my question. Hopefully this helps others.
There are two main type of endpoints in the Report Server web service, one for Management and one for execution.
The management endpoints are: ReportService2005, ReportService2006, ReportService2010
The execution endpoint is: ReportExecution2005
Therefore you can get report names, paths, data sets, etc. from ReportService2010, but to execute a report you must use ReportService2005.
So here's how you do it:
Add a web reference to the 2005 wsdl of your server, not 2010. So do this: http://<your server>/reportserver/ReportExecution2005.asmx Not this: http://<your server>/reportserver/ReportExecution2010.asmx
Import the referenc
Create an instance of ReportExecutionService: Dim rs As New ReportExecutionService. That is the 2005 executation service that has the ExecutionInfo and ExecutionHeader methods.
Reference: http://msdn.microsoft.com/en-us/library/ms155398.aspx

WriteStartElement using an Array value

I have created a XML document using visual basic in visual studio 2010.
it seems its not letting me use array values when i write a start element.
arrayValue = array(UBound(array))
Dim xw As XmlWriter = XmlWriter.Create("xmlfile.xml", xws)
xw.WriteStartDocument()
xw.WriteStartElement(arrayValue)
xw.WriteEndElement()
xw.WriteEndDocument()
xw.Flush()
xw.Close()
Wont let me do that it gives me an error and also does nothing.
"A first chance exception of type 'System.ArgumentException' occurred in System.Xml.dll"
Whats going on?
You could try using the XMLTextWriter.
arrayValue = array(UBound(array))
Dim xWriter As New Xml.XmlTextWriter("C:\Users\Admin\Desktop\mytest.xml", System.Text.Encoding.UTF8)
xWriter.Formatting = Formatting.Indented
xWriter.Indentation = 2
xWriter.WriteStartDocument(True)
xWriter.WriteStartElement(arrayValue)
xWriter.WriteEndElement()
xWriter.Flush()
xWriter.Close()
A few of my arrayValue values were not coming out as xml standard. There happen to be a lot of them.
Some started with numbers (which you cannot have as nodenames). That is why it wasn't writing to the document. I have to write a filter to change the values into XML standard.
I wish visual studio would of told me this in an error message or something. Thanks for all of your help.