How is a SOAP call possible without WSDL?

两盒软妹~` 提交于 2021-01-29 09:48:28

问题


I am confused over how my SOAP call is working below.

We had a product upgrade to our software, and the WSLDs hosted at https://"+host+"/tc/services/BotOps-2018-11-ASMLBotOps?wsdl are moved to a different location, which is not accessible via web.

My existing code looks like this:

var options = {​​​​​​​​
  url:"https://"+host+"/tc/services/BotOps-2018-11-ASMLBotOps?wsdl",
  method:'POST',
  body:xml,
  headers: {​​​​​​​​
    'Content-Type':'text/xml;charset=utf-8',
    'Content-Length':xml.length,
    'SOAPAction':"asmlValidateUserAdminBotOpsService",
    'Cookie':from
  }​​​​​​​​
}​​​​​​​​;
       
var xml = `<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:asm="http://a5oa.com/Schemas/BotOps/2018-11/ASMLBotOps">
    <soapenv:Header/>
    <soapenv:Body>
       <asm:AsmlValidateUserAdminBotOpsServiceInput>
          <asm:asmlValidateUserIsAdminOpsInput pszAsmlTcUserID="`+args[1]+`" pszRequestorUserId="`+args[2]+`"/>
       </asm:AsmlValidateUserAdminBotOpsServiceInput>
    </soapenv:Body>
 </soapenv:Envelope>`;

This worked fine without our product upgrade, which I understand. But if the WSDLs are moved to a different location which are not accessible and the url that I am referring to means nothing now, how can it be that this web service request is still working as expected? I was expecting that the web service now fails because the WSDL does not exist, but it still works.

I have read somewhere that a WSDL is like a header file in other languages, that contains the blueprint of what a SOAP accepts as input roughly and returns as output. So is it even sensible to fire a SOAP request without a WSDL?

How does this work?


回答1:


The WSDL is not your web service.

The WSDL is used to describe a web service contract so that you know how to call the web service (what operations it has, what parameter names, parameter types, where to find its endpoints, etc). You then call the web service, not the WSDL.

Another thing to mention is that you GET a WSDL (normally with the convention of using a ?wsdl parameter on the web service endpoint), but you call the web service by doing a POST. So if the service is still there and accepts POST request, it doesn't really matter from where you can retrieve its WSDL.

To provide a (possible silly) analogy, the WSDL is for a SOAP web service like a menu is to a restaurant. You can download the menu online, you can get the menu at the restaurant, or you can find the menu on the street if someone dropped it when it was transported from the printing house to the restaurant. But if you want to consume food at the restaurant, you have to go to the restaurant, you don't consume the menu itself.

Some other details you might find useful: Is it mandatory to have a WSDL definition accessible using ?wsdl?



来源:https://stackoverflow.com/questions/65598875/how-is-a-soap-call-possible-without-wsdl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!