1. Configure IIS to bind an IP address
2. Reference WebService in SL
3. Write the following code where you need to call WebService:Code:
WCF:
WCF
1 basichttpbinding basicbinding = new basichttpbinding ();
2
3 custombinding binding = new custombinding (basicbinding );
4
5 bindingelement binaryelement = new binarymessageencodingbindingelement ();
6
7 // Delete the textmessageencodingbindingelement in the original elements set
8
9binding. elements. Remove (binding. elements [0]);
10
11 // Add binarymessageencodingbindingelement
12
13binding. elements. insert (0, binaryelement );
14
15 // WCF address
16
17 endpointaddress endpoint = new endpointaddress ("http: // 172.161.100/dynamicinvokewcf. Web/dynwcf. SVC ");
18
19 // create a WCF Client
20
21 dynwcfclient client = (dynwcfclient) activator. createinstance (typeof (dynwcfclient), binding, endpoint );
22
23client. doworkcompleted + = new eventhandler <doworkcompletedeventargs> (client_doworkcompleted );
24
25client. doworkasync ();
26
27
Traditional WebService:
WebService
1 basichttpbinding basicbinding = new basichttpbinding ();
2
3 custombinding binding = new custombinding (basicbinding );
4
5 bindingelement binaryelement = new binarymessageencodingbindingelement ();
6
7 endpointaddress endpoint = new endpointaddress ("http: // 172.161.100/dynamicinvokewcf. Web/asmx. asmx ");
8
9 asmxsoapclient client = (asmxsoapclient) activator. createinstance (typeof (asmxsoapclient), binding, endpoint );
10
11client. helloworldcompleted + = new eventhandler 12
13client. helloworldasync ();
14
15
In this way, you can call WebService dynamically. The servicereferences. clientconfig file is not required at all.