I am working on share point web part development. As a client requirement we
have to generate our own web part gallery, so I prefer to write one user
control, and in that user control I display all web part definition(dwp)
file. Now user select dwp file, web part zone id and page name from drop down
and say "Add Web Part".
Ideally it should add web part to particular page to that web part zone. I
am using http://servername/_vti_bin/webpartpages.asmx web service to add web
part. I am using AddWebPart() method to add web part.
In this project when I take reference of this web reference and build
project and deploy on site then it works properly. But the problem is that
servername of this web site can be change on client side.
so I keep url of this web site configurable in web.config of share point
application. Now I read configuration and assign this value to web service
instance.
Like:
WebPartPagesWeb Service webReference = new WebPartPagesWeb Service();
webReference.Ur l = ConfigurationMa nager.AppSettin gs["WebPartService "];
webReference.Cr edentials = System.Net.Cred entialCache.Def aultCredentials ;
But when I try to execute webReference.Ad dWebPart, it gives me web service
soap exception like this
System.Web.Serv ices.Protocols. SoapHttpClientP rotocol.ReadRes ponse(SoapClien tMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall) at
System.Web.Serv ices.Protocols. SoapHttpClientP rotocol.Invoke( String
methodName, Object[] parameters) at
LicenseLink.Web Parts.WebPartSe rvice.WebPartPa gesWebService.A ddWebPart(Strin g
pageUrl, String webPartXml, Storage storage) in
D:\WebPartProje cts\LicenseLink WebParts\Web
References\WebP artService\Refe rence.cs:line 669 at
WebPartGallery. btnAddWebPart_C lick(Object sender, EventArgs e)
Please help me to resolve this issue.