Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to read response from file #243

Closed
arpymastro opened this issue Dec 17, 2018 · 12 comments
Closed

Not able to read response from file #243

arpymastro opened this issue Dec 17, 2018 · 12 comments
Labels

Comments

@arpymastro
Copy link

arpymastro commented Dec 17, 2018

I am trying to read a .xml response kept in a separate file under my mappings folder.
I have two files under my mappings folder - MyJsonReq.json and MyXmlResponse.xml
MyJsonReq.json -

/// snip ///

If I check the logs it is showing - could not be read.This file will be skipped for both MyJsonReq.json and MyXmlResponse.xml

@StefH
Copy link
Collaborator

StefH commented Dec 17, 2018

I've fixed you example, the "Headers" where wrongly defined.

It should be:

{
	"Request": {
        "Path": {
            "Matchers": [
                {
                    "Name": "WildcardMatcher",
                    "Pattern": "/myreq",
                    "IgnoreCase": false
                }
            ]
        },
        "Methods": [
            "post"
        ]
	},
	"Response":	{
		"StatusCode": 201,
		"Headers": {"Content-Type": "application/xml"},
    	        "BodyDestination": "SameAsSource",
   		"BodyAsFile": "MyXmlResponse.xml",
                "UseTransformer": false	
	}
}

Can you try this?

@StefH StefH added the question label Dec 17, 2018
@arpymastro
Copy link
Author

arpymastro commented Dec 17, 2018

@StefH - nope still it doesn't work and shows the same logs.
FYI - If I give full path (C:https://folder//folder//__admin/mappings//MyXmlResponse.xml) of my response file it works.
Is there a way to do it relatively? my response and request files both are in same mappings folder

@StefH
Copy link
Collaborator

StefH commented Dec 17, 2018

The error message is like:

2018-12-17 07:41:17 [Info] : Reading Static MappingFile : 'c:\temp-wiremock\__admin\mappings\MyXmlResponse.xml'
2018-12-17 07:41:17 [Error] : Static MappingFile : 'c:\temp-wiremock\__admin\mappings\MyXmlResponse.xml' could not be read. This file will be skipped.

This is correct, however WireMock should only read .json files and not others.

And there is a problem reading files with no path.
For now you need to use full path "BodyAsFile": "C:\\temp-wiremock\\__admin\\mappings\\MyXmlResponse.xml",

I'll check if I can update this.

See also #56

@arpymastro
Copy link
Author

If I keep "BodyAsFile" : "MyXmlResponse.xml" in my MyJsonReq.json file then i get could not be read. This file will be skipped. for both files.

If I keep "BodyAsFile" : "C:/my_full_path_to/MyXmlResponse.xml" then i get could not be read. This file will be skipped. for MyXmlResponse.xml file, which is expected.

@StefH
Copy link
Collaborator

StefH commented Dec 17, 2018

@arpymastro

If you like, you can use the NuGet from MyGet 1.0.7-ci-1623 to test this fixed code.
(see https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions)

@StefH
Copy link
Collaborator

StefH commented Dec 20, 2018

@arpymastro Are you able to use the test version MyGet 1.0.7-ci-1623 ?

@StefH
Copy link
Collaborator

StefH commented Jan 9, 2019

@arpymastro Did you have time to check?

@StefH
Copy link
Collaborator

StefH commented Jan 19, 2019

Code merged to master branch and a new NuGet will be created shortly.

@StefH StefH closed this as completed Jan 19, 2019
@NoahLerner
Copy link
Member

I still have this issue. Logs show a perfect match but the file content is not being returned by the proxy.

I've tried setting absolute and relatives paths already.. neither worked.

@StefH
Copy link
Collaborator

StefH commented Dec 2, 2019

@thewholuver94 Please create a full example project to show this error.

@NoahLerner

This comment has been minimized.

@NoahLerner
Copy link
Member

The issue was local... The xml format that I saved in added extra white space and the service I was proxying refused the entire response with the extra white space. Everything is working as it should. Thanks.

@StefH StefH added bug and removed question labels Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants