|
Hi,
I'm trying to connect to this Remote Web Service
http://217.52.114.3/kannelsending/service.asmx?op=SendSMS[^]
When I try it manually, it works, I have a username and password.
But it displays this error:
The remote server returned an error: (500) Internal Server Error.
...at this line.
HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
Do I need to encrypt the parameters or what? I'm kinda new to webservices...
Am I missing something..can someone post an example to try out?
Thanks.
|
|
|
|
|
Normally, you'd generate a set of service proxy classes to handle the communication to the server. Working at the Http level/rolling your own messages is normally tiresome and needless, thankfully there is a wsdl defining the service you want to use.
I'd suggest running wsdl.exe against http://217.52.114.3/kannelsending/service.asmx?WSDL[^], this will generate a set of proxy classes you can consume in your code.
You can also add a reference to the web service by right-clicking the project --> add service reference and using http://217.52.114.3/kannelsending/service.asmx as the service address. Don't know how well it works with external IPs, and if anything changes with the external service, it could break your code.
Refs here:
http://msdn.microsoft.com/en-us/library/ms155134.aspx[^]
|
|
|
|
|
What version of .NET framework are you using? If you are using v4.0 you can add a service reference which would make it simple or you can search the .ServiceModel for easy tools.
|
|
|
|
|
[Edit]
I went to your link, and the typical methods for accessing the web service came up.
The last example is probably what your looking for.
You'll probably have to debug the web service to see if the query strings are taken first, and make adjustments. Just load the web service file, and press F9 to mark a spot to stop at and press F5.
HTTP POST
The following is a sample HTTP POST request and response. The placeholders shown need to be replaced with actual values.
POST /kannelsending/service.asmx/SendSMS HTTP/1.1
Host: 217.52.114.3
Content-Type: application/x-www-form-urlencoded
Content-Length: length
service.asmx?UserName=string&Password=string&SMSText=string&SMSLang=string&SMSSender=string&SMSReceiver=string
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<int xmlns="http://tempuri.org/">int
modified 4-Nov-12 1:30am.
|
|
|
|