Home > Backend Development > PHP Tutorial > WebService port number modification

WebService port number modification

WBOY
Release: 2016-08-08 09:28:25
Original
1722 people have browsed it

When using the webservice interface in C#, the IP address returned to the server is accompanied by a port number. But sometimes you can't use that port (for example, using nginx for forwarding), and you need to process it on the server side (the processing content is the following code). In addition, something needs to be added to system.web in web.config in the configuration file:

<webServices>

<protocols>

< ;add name="HttpGet"/>

<add name="HttpPost"/>

<add name="HttpSoap"/>

protocols>

<soapExtensionReflectorTypes>

<add type="CommMethod.OuterPortReflector,CommMethod"/>

soapExtensionReflectorTypes& gt;

webServices >

Note: 1. The content of type is the class name and package name. This is somewhat different from what the person on msdn wrote (it may be a version problem) (http://blogs.msdn.com/b/kaevans/archive/2005/11/16/493496.aspx).

2. If there is no content in protocols, it is possible that post and get requests cannot be correctly recognized (I have not verified it, but I have seen similar problems on the blog).

3.stackoverflow source address: http://stackoverflow.com/questions/1531448/asp-net-web-service-changes-port-on-invoke


Code:

//---- -------------------------------------------------- ------------------
//
// * Copyright (C)
// * version :
// * author : ying83811
// * FileName: OuterPortReflector.cs
// * history : created by ying83811
//

//------------- -------------------------------------------------- -------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Services.Description;
namespace Better517Na.KoreaProductInterface.CommMethod
{
        ///


                                                             ’’             Rewrite ReflectMethod
          ///
;
           public override void ReflectDescription()
                   {

                                                                                                                                                                                                                                     .
            foreach ( Service service in description.Services)
                                                                                                                                                                                                                                                                                              ​SoapAddressBinding binding = extension as SoapAddressBinding;
if (null != binding)
{
                         binding.Location = binding.Location.Replace(portNum, string.Empty);                                                                                                                                                                                                                                                                                                               Location.Replace(portNum, string.Empty);
                                           Soap12AddressBinding soap12Binding = extension as Soap12AddressBinding;
                                                                                                                                                                                                                                                 Empty);
                                                                                                  
                                                                                                        }
        }
  }
}




The above introduces the modification of the WebService port number, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template