Search code examples
restsoapstubby4jstubbydb

How to set up stubby db for SOAP services


I am trying to stub SOAP services. I found that stubby4j and stubby-db both can stub SOAP services. But all the examples given are for RESTful services.

How to stub SOAP services?

Is there any advantage to use particular one? I have to stub SOAP & REST services both. Can they be stubbed in single repo? Or do I need to create 2 separate stub repos or 2 separate mapping files?


Solution

  • stubby4j and stubby-db both can be used to stub HTTP(s) calls. You can consider SOAP services as POST HTTP call with XML payload.

    Whether you should use StubbyDB or Stubby4j, it completely depends on your need.

    You need not to split into 2 projects. You can still have both stub calls in single repository. However if you go with stubby4j, you can't split mappings in two files. You can have any number of mapping files with stubby-db.

    Edit

    SOAP

    -  request:
          method: POST
          url: /soap-simulator/services/ServiceName
          post: actionName[\s\S]*mobile.([0-9]+)
    
       response:
          status: 200
          latency: 0
          headers:
                content-type: text/xml
          strategy: "first-found"
          files: ["stubs/<% post.1 %>/response.xml","stubs/ServiceName/actionName/default.xml"]
    

    REST

    -  request:
          method: POST
          url: /soap-simulator/services/ServiceName/actionName
          post: mobile.([0-9]+)
    
       response:
          status: 200
          latency: 0
          headers:
                content-type: text/xml
          strategy: "first-found"
          files: ["stubs/<% post.1 %>/response.xml","stubs/ServiceName/actionName/default.xml"]