Quantcast
Channel: CRM Development 論壇
Viewing all articles
Browse latest Browse all 10280

[CRM 2011] Connection problem with Organization URI

$
0
0

Hi,

This is a relatively simple question however I was not able to figure out the reason why the system is behaving this way.

I have the following code to connect to CRM:

// strurl is a parameter and has the  data "http://<server name>/<org name>/XRMServices/2011/OrganizationData.svc"

            Dim organizationUri As New Uri(strurl)
            Dim cred As ClientCredentials = New ClientCredentials()

            cred.UserName.UserName = //User name in the format "Domain\User Name"
            cred.UserName.Password = "Password"

            Dim _serviceproxy As New OrganizationServiceProxy(organizationUri, Nothing, cred, Nothing)
            _serviceproxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(New ProxyTypesBehavior())

            Dim _service As IOrganizationService
            _service = _serviceproxy

           

            Dim request1 As WhoAmIRequest = New WhoAmIRequest()
            Dim response1 As WhoAmIResponse = New WhoAmIResponse()
            Try
                response1 = CType(_service.Execute(request1), WhoAmIResponse)
            Catch exception As Exception
            End Try

The idea is to connect to CRM and retrieve the User ID who is calling this code.  I am using early bound entity types and the appropriate code file had already been included in the project and the entity types are recognized.  However, whenever I get to the bolded line above to create the OrganizationServiceProxy, it would return an error and crash.  The error I got was this:

"Metadata contains a reference that cannot be resolved: 'http://<Server Name>/XRMServices/2011/OrganizationData.svc?wsdl'.

It looks like for some reason the organization name on the URL had been stripped out.  Any possible reason for that?  Am I missing anything in the code above?

Thanks!


Viewing all articles
Browse latest Browse all 10280

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>