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:
WebPartPagesWebService webReference = new WebPartPagesWebService();
webReference.Url = ConfigurationManager.AppSettings["WebPartService"];
webReference.Credentials = System.Net.CredentialCache.DefaultCredentials;
But when I try to execute webReference.AddWebPart, it gives me web service
soap exception like this
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall) at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters) at
LicenseLink.WebParts.WebPartService.WebPartPagesWebService.AddWebPart(String
pageUrl, String webPartXml, Storage storage) in
D:\WebPartProjects\LicenseLinkWebParts\Web
References\WebPartService\Reference.cs:line 669 at
WebPartGallery.btnAddWebPart_Click(Object sender, EventArgs e)
Please help me to resolve this issue.
John Saunders [MVP] - 19 Apr 2007 22:37 GMT
...
> But when I try to execute webReference.AddWebPart, it gives me web service
> soap exception like this
[quoted text clipped - 9 lines]
> References\WebPartService\Reference.cs:line 669 at
> WebPartGallery.btnAddWebPart_Click(Object sender, EventArgs e)
Please post the entire exception. You have only supplied us with the stack
trace.

Signature
John Saunders [MVP]
SachinG - 20 Apr 2007 09:42 GMT
Hi John,
Actually when I update web reference and change URL of web service, than it
working fine.
Thanks for your kind attention for my problem.
> ....
>
[quoted text clipped - 14 lines]
> Please post the entire exception. You have only supplied us with the stack
> trace.