Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

cal-schleupen
Copy link
Contributor

@cal-schleupen cal-schleupen commented Sep 29, 2023

We have round about 4800 WCF Services in our landscape, thus this faker is really helpful. In order to write more easy request body matchers I would like to write more easy xpath expressions using the xpath matcher as follows:

{
    "Title": "wcf test",
    "Request": {
        "Path": {
            "Matchers": [
                {
                    "Name": "WildcardMatcher",
                    "Pattern": "/MyService.svc"
                }
            ]
        },
        "Methods": [
            "post"
        ],
                "Headers": [
                    {
                        "Name": "Content-Type",
                        "Matchers": [
                            {
                                "Name": "WildcardMatcher",
                                "Pattern": "text/xml; charset=utf-8",
                                "IgnoreCase": true
                            }
                        ],
                        "IgnoreCase": true
                    },
                    {
                        "Name": "SOAPAction",
                        "Matchers": [
                            {
                                "Name": "WildcardMatcher",
                                "Pattern": "*urn://MyService/Query*",
                                "IgnoreCase": true
                            }
                        ],
                        "IgnoreCase": true
                    }
                ],
        "Body": {
            "Matcher": {
                "Name": "XPathMatcher",
                "Pattern": "/s:Envelope/s:Body/q:QueryRequest",
                "XmlNamespaceMap": [
                    { 
                        "Prefix": "s",
                        "Uri": "http://schemas.xmlsoap.org/soap/envelope/"
                    },
                    { 
                        "Prefix": "i",
                        "Uri": "http://www.w3.org/2001/XMLSchema-instance"
                    },
                    { 
                        "Prefix": "q",
                        "Uri": "urn://Schleupen.AS.MT.BIB.Buecher.BuchQueryService_3.1"
                    }
                ]
            }
        }
    },
    "Response": {
        "StatusCode": 200,
        "Body": "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body><QueryResponse xmlns=\"urn://MyService\"></QueryResponse></s:Body></s:Envelope>",
        "Headers": {
            "Content-Type": "text/xml"
        }
    }
}

This implementation handles this so that

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header></s:Header><s:Body><QueryRequest xmlns="urn://MyService"><MaxResults i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/><Restriction i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/><SearchMode i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/></QueryRequest></s:Body></s:Envelope> 

matches for example.

Yes, I can use 'local-name()' etc. but I think this way it is more easy.

@StefH StefH added the feature label Sep 29, 2023
@StefH
Copy link
Collaborator

StefH commented Sep 30, 2023

@cal-schleupen
Thank you for this addition.

I did add some review comments, can you please take a look?

@cal-schleupen
Copy link
Contributor Author

cal-schleupen commented Sep 30, 2023

Hi Stef,

thanks a lot for reviewing it so fast! I'm really impressed and I like WireMock.NET a lot. It is also well done under the hood. This weekend I am a little bit busy with my family, but I'll fix it not later than on Monday. Hopefully today ;-)

I am really happy that you could take a look at my pull request!

Kind regards,
Carsten

@cal-schleupen cal-schleupen requested a review from StefH October 2, 2023 09:10
Copy link
Collaborator

@StefH StefH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you take a look

@cal-schleupen
Copy link
Contributor Author

Maybe we got it now ;-)

@cal-schleupen cal-schleupen reopened this Oct 2, 2023
@cal-schleupen cal-schleupen requested a review from StefH October 2, 2023 11:36
@StefH
Copy link
Collaborator

StefH commented Oct 2, 2023

@cal-schleupen
Thank you.

I'll merge this and create a new NuGet.

@StefH StefH merged commit 60bf12e into wiremock:master Oct 2, 2023
@cal-schleupen cal-schleupen deleted the XmlNamespaceSupport-XPathMather branch October 3, 2023 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants