Hi<br>
I have asmx url like https://test.aspx?wsdl ,method name, arguments as object array.<br>
Can I write<br>
Methodinfo mi=was .Gettype().Get method(method name )<br>
Var result=mi.invoke(classinstance,parameter as object array)<br>
<br>
Do you mean you want to call the asmx using reflection?
If so, you could.
Below is my test sample.
MyServiceSoapClient client = (MyServiceSoapClient)
Activator.CreateInstance(typeof(MyServiceSoapClient)); // use reflection to create client instance
MethodInfo info= typeof(MyServiceSoapClient).GetMethod("HelloWorld"); // get method info of method HelloWorld
string result =(string) info.Invoke(client, new object[] { "my test parameter" }); // invoke the method
Response.Write(result); // output the result
My Service
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class MyService : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld(string arg)
{
return arg;
}
}
The result.
Best regards,
Ackerly Xu
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue.
Not know clearly what you mean , but if you want to pass datatable to your MethodInfo as parameter, you don't need to do any convertion, just pass your datatable to the object array.
If this is not your case , could you specify your problem or post the code you have tried and show us what problem you have met?
Datatable should have no difference from string when calling web method.
Member
5 Points
257 Posts
Consume soaprequest
Jan 30, 2019 12:49 PM|Guhananth|LINK
Hi<br>
I have asmx url like https://test.aspx?wsdl ,method name, arguments as object array.<br>
Can I write<br>
Methodinfo mi=was .Gettype().Get method(method name )<br>
Var result=mi.invoke(classinstance,parameter as object array)<br>
<br>
Contributor
2290 Points
903 Posts
Re: Consume soaprequest
Jan 31, 2019 01:45 AM|Ackerly Xu|LINK
Hi Guhananth,
Do you mean you want to call the asmx using reflection?
If so, you could.
Below is my test sample.
My Service
The result.
Best regards,
Ackerly Xu
Please remember to "Mark as Answer" the responses that resolved your issue.
Member
5 Points
257 Posts
Re: Consume soaprequest
Jan 31, 2019 02:02 AM|Guhananth|LINK
Ackerly
Looks good . what is . i want to convert to datatable . and then convert to object
MyServiceSoapClient is this asmx url ? like https://test/wsdl?
Contributor
2290 Points
903 Posts
Re: Consume soaprequest
Jan 31, 2019 09:30 AM|Ackerly Xu|LINK
Hi Guhananth,
Not know clearly what you mean , but if you want to pass datatable to your MethodInfo as parameter, you don't need to do any convertion, just pass your datatable to the object array.
If this is not your case , could you specify your problem or post the code you have tried and show us what problem you have met?
Datatable should have no difference from string when calling web method.
https://stackoverflow.com/questions/4966189/can-we-pass-dataset-to-a-web-service-method-if-yes-then-how
Best regards,
Ackerly Xu
Please remember to "Mark as Answer" the responses that resolved your issue.
Member
5 Points
257 Posts
Re: Consume soaprequest
Feb 01, 2019 01:38 AM|Guhananth|LINK
hi
In your code where it is mentioned
MyServiceSoapClient
Contributor
2290 Points
903 Posts
Re: Consume soaprequest
Feb 01, 2019 02:59 AM|Ackerly Xu|LINK
Hi Guhananth,
It is generated by visual studio after I add service reference to the asmx.
Right click your asmx, click view in browser.
The following page should appear.
copy its address, and right click your project's references , click add service reference, paste the address into the wizard's address bar.
Click ok. The client should generated.Look for it in your project's connected services.
Click it to find your client. It usually ends with Client.
Best regards,
Ackerly Xu
Please remember to "Mark as Answer" the responses that resolved your issue.