Spring. Net closed service class focuses on WebService and issues,
In a recent project, the title method is used, and Spring is used. net closed the service class into WebService for other places to call and use, it still feels quite fresh, so I searched an article written by my friends in the Garden (here) I tried to build an environment, and finally ran smoothly. But I encountered several problems in the middle. Let's record them here.
The specific setup method will not be described in detail. The above Article is clear and the main problems are as follows:
1. configuration file Introduction Method
In the configuration file web. when I reference the spring.net configuration file in config, I did not create a new configuration file as in the previous article, but created a configuration file called settings. xml files, but the results are the same. spring.net can recognize them because the config file itself is an xml file. Then, introduce the configuration file to the context node in the web. confg file, and follow the <resource uri = "~ /Settings. xml "/> is okay. It can be started and encapsulated successfully, but in another way, <resource uri =" aeesmbly: // Spring. net/Spring. net/settings. xml "/> (in general, we use this method in actual projects, because we all layer the project, and different layers focus on and process different services, the method above applies to referencing the currentProject setIn the configuration file, this method is used to reference the configuration files of other projects.) If a problem occurs, the InputStream is thrown as null, but the configuration file is not found, the reason is no.You can set the settings. xml file to "embedded file" (set in properties).
2. Remote Call
After successful startup, click the method name on the page and then click the call button to view the returned results. However, in another project, a problem occurs when WebClient is called, throw "the remote server closes an existing connection" and finds that you can only view the result by clicking the call button. You cannot copy the address in another browser and press Enter.The reason is that the Remote Call protocol is not added to the configuration file web. config. Add the following code under the system. web node:.
<webServices> <protocols> <add name="HttpPost"/> <add name="HttpGet"/> </protocols> </webServices>
3. Return Value Problems
The WebService encapsulated in this method has a problem that I have not found a solution yet, that is, the returned value is of the xml type, you cannot set the type in the request header to control the return value type (such as json format), which is a string of the xml type.