soapgraphqlgraphql-jsgraphql-mesh

Unable to get soap response after Graphql mesh upgrade


I have upgraded graphql-mesh/soap versions and other dependencies. And my soap wsdl is using soap1.1 features.

After update I am unable to connect to soap client as it is returning 500 error due to version mismatch in namespace created by graphqlmesh soap in request.

I have configured soap handler in .meshrc.yaml with source url

Expected namespace in request body -http://schemas.xmlsoap.org/soap/envelope

And generating - http://www.w3.org/2003/05/soap-envelope


Solution

  • Manage to modify the namespace using custome-fect.

    sources:
      - name: myser
        handler:
          soap:
            source: http://127.0.0.1:8080/myser.wsdl
            operationHeaders:
              Content-Type: text/xml;charset=utf-8
              Accept-Encoding: gzip,deflate   
    customFetch: ./custom-fetch.ts     
    serve:
      endpoint: /api/graphql 
      port: 5000
    

    my custom -fetch.js

    import { fetch } from '@whatwg-node/fetch'
     
    export default async function ( url: string, options: RequestInit = {} )
    {
        console.log(url)
        if ( url === 'http://127.0.0.1:8080/myserv' )
        {
            console.log(options.body)
            if (options.body && typeof options.body === 'string')
            {
                let body = options.body;
                if (typeof body === 'string') {
                    body = body.replace(
                      '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">',
                      '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >'
                    );
            
    
                    options.body = body;
                    console.log('Modified xml body:', options.body);
                }        
            }
        }
        
        return fetch(url, options);
    }