force code to use internal web site url instead of extranet url
- Hi,
Is there a way to force my .net assembly to use internal relative path instead of extranet one when querying a SharePoint/PerformancePoint webservice ?
I'm asking this because we implemented a code that is working fine if we browse the site using the internal url, but when we try to trigger it from the extranet url it fails throwing "CannotReachServerException".
Is there a method to retrieve the internal host header from the web application ?
Regards,
Dejan
Answers
Hi,
"Is there a method to retrieve the internal host header from the web application ?"
You can get that using code that runs on the server built on the object model, but not using OOB WSs.
The SPServerBinding class (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spiissettings.serverbindings.aspx) contains info about the HostHeader.
If you know the GUID of your site, you can get the host header for the intranet zone like this:
SPSite site = new SPSite(guidOfYourSite, SPUrlZone.Intranet);
String hostHeader = site.IisSetting.ServerBindings.HostHeader;
If you need that using WS, you should implement your custom WS, like shown in these posts:
Walkthrough: Creating a Custom Web Service
http://msdn.microsoft.com/en-us/library/ms464040.aspx
Creating a Custom Web Service for SharePoint
http://it.toolbox.com/blogs/sharepoint-blog/creating-a-custom-web-service-for-sharepoint-13553
SharePoint for Developers Part 6 – Custom web services
http://blogs.msdn.com/kaevans/archive/2009/04/30/sharepoint-for-developers-part-6-custom-web-services.aspx
Hope that helps you to solve the issue.
Peter- Marked As Answer byAaron Han - MSFTModeratorFriday, November 13, 2009 10:26 AM
- Proposed As Answer byAaron Han - MSFTModeratorSaturday, November 07, 2009 12:58 AM
All Replies
Hi, Dejan
Would you please tell me how did you reference webservice url?
Can you set its value at runtime via code?
Thanks for your understanding.
Best Regards,
-Aaron
Hi,
"Is there a method to retrieve the internal host header from the web application ?"
You can get that using code that runs on the server built on the object model, but not using OOB WSs.
The SPServerBinding class (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spiissettings.serverbindings.aspx) contains info about the HostHeader.
If you know the GUID of your site, you can get the host header for the intranet zone like this:
SPSite site = new SPSite(guidOfYourSite, SPUrlZone.Intranet);
String hostHeader = site.IisSetting.ServerBindings.HostHeader;
If you need that using WS, you should implement your custom WS, like shown in these posts:
Walkthrough: Creating a Custom Web Service
http://msdn.microsoft.com/en-us/library/ms464040.aspx
Creating a Custom Web Service for SharePoint
http://it.toolbox.com/blogs/sharepoint-blog/creating-a-custom-web-service-for-sharepoint-13553
SharePoint for Developers Part 6 – Custom web services
http://blogs.msdn.com/kaevans/archive/2009/04/30/sharepoint-for-developers-part-6-custom-web-services.aspx
Hope that helps you to solve the issue.
Peter- Marked As Answer byAaron Han - MSFTModeratorFriday, November 13, 2009 10:26 AM
- Proposed As Answer byAaron Han - MSFTModeratorSaturday, November 07, 2009 12:58 AM


