使用此代码,EndcreateUser方法返回的结果始终为null:
ServiceReference1.CustomerClient c = new CustomerClient();
IAsyncResult asyncResult = c.BegincreateUser(
WebApplication1.ServiceReference1.Credential credential,
WebApplication1.ServiceReference1.User user,
int accountType,
**System.AsyncCallback callback, object asyncState**);
asyncResult.AsyncWaitHandle.WaitOne();
UserCreateResult userResult = c.EndcreateUser(asyncResult);
当我尝试使用其他方法发送XML时,它是有效的,但它没有用,因为我必须自己创建所有XML代码:
XmlDocument soapEnvelopeXml = p_xmlDocument;
HttpWebRequest webRequest = CreateWebRequest(_url, _action);
InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest);
// begin async call to web request.
IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null);
// suspend this thread until call is complete. You might want to
// do something usefull here like update your UI.
asyncResult.AsyncWaitHandle.WaitOne();
// get the response from the completed web request.
string soapResult;
using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))
using (StreamReader rd = new StreamReader(webResponse.GetResponseStream()))
{
soapResult = rd.ReadToEnd();
}
我不知道为什么,你有什么想法吗?