为什么信封中没有SOAPAction甚至操作名的SOAP请求仍然有效?

为什么信封中没有SOAPAction甚至操作名的SOAP请求仍然有效?,soap,Soap,我遇到了一件奇怪的事情: 我将SOAP请求发送给SOAP服务提供者,SOAP请求信封在主体中没有SOAPAction头和操作名称。但是反应还是可以的。 这是我的WSDL <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tn

我遇到了一件奇怪的事情: 我将SOAP请求发送给SOAP服务提供者,SOAP请求信封在主体中没有SOAPAction头和操作名称。但是反应还是可以的。 这是我的WSDL

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:com.tung.switchyard:soap-hello:1.0" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="IHello" targetNamespace="urn:com.tung.switchyard:soap-hello:1.0">
  <wsdl:types>
<xs:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:com.tung.switchyard:soap-hello:1.0" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="urn:com.tung.switchyard:soap-hello:1.0" version="1.0">
<xs:element name="greetingResponse" type="tns:greetingResponse"/>
<xs:element name="person" type="tns:person"/>
<xs:complexType name="person">
    <xs:sequence>
      <xs:element minOccurs="0" name="name" type="xs:string"/>
      <xs:element name="sex" type="xs:boolean"/>
    </xs:sequence>
  </xs:complexType>
<xs:complexType name="greetingResponse">
    <xs:sequence>
      <xs:element minOccurs="0" name="response" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
            <xs:element name="NewOperation">
                <xs:complexType>
                    <xs:sequence>

                        <xs:element name="in" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="NewOperationResponse">
                <xs:complexType>
                    <xs:sequence>

                        <xs:element name="out" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
</xs:schema>
  </wsdl:types>
  <wsdl:message name="hello">
    <wsdl:part element="tns:person" name="arg0">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="NewOperationRequest">
    <wsdl:part element="tns:person" name="argo">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="helloResponse">
    <wsdl:part element="tns:greetingResponse" name="return">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="NewOperationResponse">
    <wsdl:part element="tns:greetingResponse" name="return">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="IHelloPortType">
    <wsdl:operation name="hello">
      <wsdl:input message="tns:hello" name="hello">
    </wsdl:input>
      <wsdl:output message="tns:helloResponse" name="helloResponse">
    </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="NewOperation">
      <wsdl:input message="tns:NewOperationRequest">
    </wsdl:input>
      <wsdl:output message="tns:NewOperationResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="IHelloSoapBinding" type="tns:IHelloPortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="hello">
      <soap:operation soapAction="hello" style="document"/>
      <wsdl:input name="hello">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="helloResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="NewOperation">
      <soap:operation soapAction="NewOperation" style="document"/>
      <wsdl:input name="NewOperationRequest">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="NewOperationResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="IHello">
    <wsdl:port binding="tns:IHelloSoapBinding" name="IHelloPort">
      <soap:address location="http://localhost:8080/soap-hello/IHello"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

请求信封

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:com.tung.switchyard:soap-hello:1.0">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:person>
         <name>John</name><sex>true</sex>
      </urn:person>
   </soapenv:Body>
</soapenv:Envelope>

约翰特鲁
答复:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/>
   <soap:Body>
      <greetingResponse xmlns="urn:com.tung.switchyard:soap-hello:1.0">
         <response>Hello John</response>
      </greetingResponse>
   </soap:Body>
</soap:Envelope>

你好,约翰

在您的WSDL文件中,您提到了这两个服务的soap操作属性,并且这两个服务具有相同的请求和响应元素。SOAP操作属性是在Http Post头中发送的。当您在没有SOAP操作的情况下发送它时,它将失败。我已经执行了一个测试,下面是日志

没有SOAP操作

POST /DemoWS/services/IHello HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Host: localhost:8080
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 375

Request Envelope

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><person xmlns="urn:com.tung.switchyard:soap-hello:1.0"><name xmlns="">Test</name><sex xmlns="">true</sex></person></soapenv:Body></soapenv:Envelope>

Error Response Envelope

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><axis2ns2:Fault xmlns:axis2ns2="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>axis2ns2:Client</faultcode><faultstring>The endpoint reference (EPR) for the Operation not found is http://localhost:8080/DemoWS/services/IHello and the WSA Action = . If this EPR was previously reachable, please contact the server administrator.</faultstring><detail/></axis2ns2:Fault></soapenv:Body></soapenv:Envelope>
POST/DemoWS/services/IHello HTTP/1.0
内容类型:text/xml;字符集=utf-8
接受:应用程序/soap+xml、应用程序/dime、多部分/相关、文本/*
用户代理:Axis/1.4
主机:本地主机:8080
缓存控制:没有缓存
Pragma:没有缓存
SOAPAction:“
内容长度:375
请求信封
测试正确
错误响应包络
axis2ns2:Client找不到操作的端点引用(EPR)http://localhost:8080/DemoWS/services/IHello WSA操作=。如果以前可以访问此EPR,请与服务器管理员联系。
使用SOAP操作-效果良好

POST /DemoWS/services/IHello HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Host: localhost:8080
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "NewOperation"
Content-Length: 375

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><person xmlns="urn:com.tung.switchyard:soap-hello:1.0"><name xmlns="">Test</name><sex xmlns="">true</sex></person></soapenv:Body></soapenv:Envelope>
POST/DemoWS/services/IHello HTTP/1.0
内容类型:text/xml;字符集=utf-8
接受:应用程序/soap+xml、应用程序/dime、多部分/相关、文本/*
用户代理:Axis/1.4
主机:本地主机:8080
缓存控制:没有缓存
Pragma:没有缓存
SOAPAction:“新操作”
内容长度:375
测试正确

您也可以分享响应吗?你好,Ashraf,请检查我添加的响应您使用的是SOAP UI吗?或者生成一个客户端?不,我使用java代码发送请求