locked
WebService (SOAP) - Remove the Protocol suffix in wsdl file RRS feed

  • Question

  • User-2135312661 posted

    I want to remove the Protocol suffix: Soap, SoapIn, SoapOut

    <?xml version="1.0" encoding="utf-8"?>
    <wsdl:definitions xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.proiam.com/PMItemAndLocationEnquiry/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://www.proiam.com/PMItemAndLocationEnquiry/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
      <wsdl:types>
        <s:schema elementFormDefault="qualified" targetNamespace="http://www.proiam.com/PMItemAndLocationEnquiry/">
          <s:element name="getCompleteItemNumberRequest" type="s:string" />
          <s:element name="getCompleteItemNumberResponse">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="unbounded" form="unqualified" name="ItemNumber" type="s:string" />
              </s:sequence>
              <s:attribute name="ErrorMessage" type="s:string" />
              <s:attribute name="ErrorCode" type="s:int" />
              <s:attribute name="BarCodeCount" type="s:int" />
            </s:complexType>
          </s:element>
          <s:element name="ListPostOfficeRequest" type="s:string" />
          <s:element name="ListPostOfficesResponse">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="ListPostOfficeResult" type="tns:ListPostOfficeResultType" />
              </s:sequence>
            </s:complexType>
          </s:element>
          <s:complexType name="ListPostOfficeResultType">
            <s:complexContent mixed="false">
              <s:extension base="tns:ListPostOfficesResultBaseType">
                <s:sequence>
                  <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="PostOffices" type="tns:ArrayOfPostOffice" />
                </s:sequence>
              </s:extension>
            </s:complexContent>
          </s:complexType>
          <s:complexType name="ListPostOfficesResultBaseType">
            <s:sequence>
              <s:element minOccurs="1" maxOccurs="1" form="unqualified" name="ErrorCode" type="s:int" />
              <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="ErrorMessage" type="s:string" />
            </s:sequence>
          </s:complexType>
          <s:complexType name="ArrayOfPostOffice">
            <s:sequence>
              <s:element minOccurs="0" maxOccurs="unbounded" form="unqualified" name="PostOffice" type="tns:PostOffice" />
            </s:sequence>
          </s:complexType>
          <s:complexType name="PostOffice">
            <s:attribute name="Name" type="s:string" />
            <s:attribute name="Code" type="s:string" />
          </s:complexType>
          <s:element name="ValidationPriorCaseCreationRequest">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="1" maxOccurs="1" form="unqualified" name="Request_Type">
                  <s:simpleType>
                    <s:restriction base="s:string">
                      <s:enumeration value="V" />
                      <s:enumeration value="D" />
                      <s:enumeration value="S" />
                      <s:enumeration value="M" />
                      <s:enumeration value="P" />
                      <s:enumeration value="Q" />
                    </s:restriction>
                  </s:simpleType>
                </s:element>
                <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="Po_Code" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="PoTransfer_Code" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="Prefered_Date" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="Contact_No" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="Po_Postal_Code" type="s:string" />
              </s:sequence>
              <s:attribute name="Item_No" type="s:string" />
            </s:complexType>
          </s:element>
          <s:element name="ValidationPriorCaseCreationResponse">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="Result_Code" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="Return_Msg" type="s:string" />
              </s:sequence>
              <s:attribute name="Item_No" type="s:string" />
            </s:complexType>
          </s:element>
          <s:element name="getItemInfoRequest" type="tns:GetItemInfoType" />
          <s:complexType name="GetItemInfoType">
            <s:sequence>
              <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="ItemNumber" type="s:string" />
              <s:element minOccurs="1" maxOccurs="1" form="unqualified" name="IncludeStandardInfo" type="s:boolean" />
              <s:element minOccurs="1" maxOccurs="1" form="unqualified" name="IncludeTrackAndTraceEvent" type="s:boolean" />
              <s:element minOccurs="1" maxOccurs="1" form="unqualified" name="IncludeArchiveDataBase" nillable="true" type="s:boolean" />
            </s:sequence>
          </s:complexType>
          <s:element name="getItemInfoResponse" type="s:string" />
        </s:schema>
      </wsdl:types>
      <wsdl:message name="getCompleteItemNumberSoapIn">
        <wsdl:part name="getCompleteItemNumberRequest" element="tns:getCompleteItemNumberRequest" />
      </wsdl:message>
      <wsdl:message name="getCompleteItemNumberSoapOut">
        <wsdl:part name="getCompleteItemNumberResult" element="tns:getCompleteItemNumberResponse" />
      </wsdl:message>
      <wsdl:message name="listPostOfficesSoapIn">
        <wsdl:part name="ListPostOfficeRequest" element="tns:ListPostOfficeRequest" />
      </wsdl:message>
      <wsdl:message name="listPostOfficesSoapOut">
        <wsdl:part name="listPostOfficesResult" element="tns:ListPostOfficesResponse" />
      </wsdl:message>
      <wsdl:message name="validationPriorCaseCreationSoapIn">
        <wsdl:part name="ValidationPriorCaseCreationRequest" element="tns:ValidationPriorCaseCreationRequest" />
      </wsdl:message>
      <wsdl:message name="validationPriorCaseCreationSoapOut">
        <wsdl:part name="validationPriorCaseCreationResult" element="tns:ValidationPriorCaseCreationResponse" />
      </wsdl:message>
      <wsdl:message name="getItemInfoSoapIn">
        <wsdl:part name="getItemInfoRequest" element="tns:getItemInfoRequest" />
      </wsdl:message>
      <wsdl:message name="getItemInfoSoapOut">
        <wsdl:part name="getItemInfoResult" element="tns:getItemInfoResponse" />
      </wsdl:message>
      <wsdl:portType name="PMItemAndLocationEnquirySoap">
        <wsdl:operation name="getCompleteItemNumber">
          <wsdl:input message="tns:getCompleteItemNumberSoapIn" />
          <wsdl:output message="tns:getCompleteItemNumberSoapOut" />
        </wsdl:operation>
        <wsdl:operation name="listPostOffices">
          <wsdl:input message="tns:listPostOfficesSoapIn" />
          <wsdl:output message="tns:listPostOfficesSoapOut" />
        </wsdl:operation>
        <wsdl:operation name="validationPriorCaseCreation">
          <wsdl:input message="tns:validationPriorCaseCreationSoapIn" />
          <wsdl:output message="tns:validationPriorCaseCreationSoapOut" />
        </wsdl:operation>
        <wsdl:operation name="getItemInfo">
          <wsdl:input message="tns:getItemInfoSoapIn" />
          <wsdl:output message="tns:getItemInfoSoapOut" />
        </wsdl:operation>
      </wsdl:portType>
      <wsdl:binding name="PMItemAndLocationEnquirySoap" type="tns:PMItemAndLocationEnquirySoap">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="getCompleteItemNumber">
          <soap:operation soapAction="http://www.proiam.com/PMItemAndLocationEnquiry/getCompleteItemNumber" style="document" />
          <wsdl:input>
            <soap:body use="literal" />
          </wsdl:input>
          <wsdl:output>
            <soap:body use="literal" />
          </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="listPostOffices">
          <soap:operation soapAction="http://www.proiam.com/PMItemAndLocationEnquiry/listPostOffices" style="document" />
          <wsdl:input>
            <soap:body use="literal" />
          </wsdl:input>
          <wsdl:output>
            <soap:body use="literal" />
          </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="validationPriorCaseCreation">
          <soap:operation soapAction="http://www.proiam.com/PMItemAndLocationEnquiry/validationPriorCaseCreation" style="document" />
          <wsdl:input>
            <soap:body use="literal" />
          </wsdl:input>
          <wsdl:output>
            <soap:body use="literal" />
          </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="getItemInfo">
          <soap:operation soapAction="http://www.proiam.com/PMItemAndLocationEnquiry/getItemInfo" style="document" />
          <wsdl:input>
            <soap:body use="literal" />
          </wsdl:input>
          <wsdl:output>
            <soap:body use="literal" />
          </wsdl:output>
        </wsdl:operation>
      </wsdl:binding>
      <wsdl:service name="PMItemAndLocationEnquiry">
        <wsdl:port name="PMItemAndLocationEnquirySoap" binding="tns:PMItemAndLocationEnquirySoap">
          <soap:address location="http://localhost:57919/PMItemAndLocationEnquiry.asmx" />
        </wsdl:port>
      </wsdl:service>
    </wsdl:definitions>

    Monday, July 24, 2017 2:35 PM

All replies

  • User1168443798 posted

    Hi JohnnyKhandN,

    >> I want to remove the Protocol suffix: Soap, SoapIn, SoapOut

    Do you want to change all the appears? If so, I am afraid it is impossible. As my test, we could not change the name of message in wsdl:input.

    Here is a simple demo to modify SOAP for a test.

    1. Add ChangeSoapReflector.cs under App_Code

    namespace WebAPI.App_Code
    {
        public class ChangeSoapReflector : SoapExtensionReflector
        {
            public override void ReflectMethod()
            {
            }
            public override void ReflectDescription()
            {
                ServiceDescription description = ReflectionContext.ServiceDescription;
                //change message name
                foreach (Message message in description.Messages)
                {
                    message.Name = message.Name.Replace("SoapIn","");
                    message.Name = message.Name.Replace("SoapOut", "");
                }
                foreach (PortType portType in description.PortTypes)
                {
                    portType.Name = portType.Name.Replace("Soap", "");
                    foreach (Operation operation in portType.Operations)
                    {
                        foreach (var operationMessage in operation.Messages)
                        {
                            if (operationMessage.GetType() == typeof(OperationInput))
                            {
                                //this is read-only, we could not change it
                                System.Diagnostics.Debug.WriteLine(((OperationInput)operationMessage).Message.Name);
                            }
                        }
                    }
                }
            }
        }
    }

    2.Modify the web.config

      <system.web>
        <--other elements-->
        <webServices>
          <soapExtensionReflectorTypes>
            <add type="WebAPI.App_Code.ChangeSoapReflector, App_code"/>
          </soapExtensionReflectorTypes>
        </webServices>
      </system.web>
    

    3.Run service

    Best Regards,

    Edward

    Tuesday, July 25, 2017 5:41 AM