0

Im trying to use "invoke-webrequest" CMDLET for callin a web service. Im successfully using it with WSDL served by apache tomcat,, but when I use it against glassfish 2 I get:

---Invoke-WebRequest : '"utf-8"' is not a supported encoding name.---

My request works in SOAP UI just well, but using SOAP UI I realize Glassfish V2 is setting the UTF-8 encoding with double quotes around (see the error above and will give you the clue). Apache Tomcat does it just well, it gives me the encoding without the double quotes.

How do you deal with this? is there any way to remove those double quotes dynamically or maybe replace the encoding altogether during the CMDLET call? I could find any reference to this on the documentation.

Thanks!

1 Answer 1

1

Invoke-WebRequest is just setting up a plain old HTTP header/body request for you. Are you sure you're creating the correct envelope with header and body with all the correct XML namespaces etc? I'm not saying you can't do this but in general, it might be easier to use New-WebServiceProxy to create a proxy against the WSDL for the service.

If you still want to go this way, just pass in a hashtable with all the headers you want to use, including the one that sets the charset e.g.:

Invoke-WebRequest ... -Headers @{Host = 'www.xxxx.xxx';
                                 Content-Type = 'application/soap+xml; charset=utf-8';
                                 Content-Length = <length>;
                                 SOAPAction = 'http://www.w3.org/2003/05/soap-envelope;
                                 ...}
Sign up to request clarification or add additional context in comments.

1 Comment

I tried using the New-WebServiceProxy, but I was having a ton of problems assigning the result to a variable,,, so I switched gears. I just realized that I cannot use Invoke-Webrequest, because I dont have Powershell 3.0 on the host server,, so I will go back to New-WebServiceProxy. I will post my question on that on a different thread,,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.