2
* JBoss, Home of Professional Open Source
3
* Copyright 2005, JBoss Inc., and individual contributors as indicated
4
* by the @authors tag. See the copyright.txt in the distribution for a
5
* full listing of individual contributors.
7
* This is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU Lesser General Public License as
9
* published by the Free Software Foundation; either version 2.1 of
10
* the License, or (at your option) any later version.
12
* This software is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this software; if not, write to the Free
19
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23
package org.jboss.test.remoting.marshall.http.metadata;
25
import junit.framework.TestCase;
26
import org.apache.log4j.Level;
27
import org.jboss.remoting.Client;
28
import org.jboss.remoting.InvokerLocator;
30
import java.util.HashMap;
31
import java.util.List;
33
import java.util.Properties;
36
* Test case that uses the HTTPInvoker client to call on two different public SOAP services (one based
37
* on Axis and the other based on .NET implementations).
39
* @author <a href="mailto:telrod@e2technologies.net">Tom Elrod</a>
41
public class HTTPUnMarshallerMetadataTestCase_Retired extends TestCase
43
private Client client;
45
public void init(String httpTargetURL, HTTPUnMarshallerMock unmarshaller)
49
InvokerLocator locator = new InvokerLocator(httpTargetURL);
50
client = new Client(locator);
52
client.setUnMarshaller(unmarshaller);
61
public String makeInvocationCall(String httpTargetURL, String payload, Map metadata, HTTPUnMarshallerMock unmarshaller) throws Throwable
63
init(httpTargetURL, unmarshaller);
65
Object obj = client.invoke(payload, metadata);
67
System.out.println("invoke returned" + obj);
72
public void testWeatherHTTPInvocation() throws Throwable
75
org.apache.log4j.BasicConfigurator.configure();
76
org.apache.log4j.Category.getRoot().setLevel(Level.INFO);
77
org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO);
78
org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG);
79
org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG);
82
String testURL = "http://services.xmethods.net:80/soap/servlet/rpcrouter";
84
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
85
"<soap:Envelope xmlns:mrns0=\"urn:xmethods-Temperature\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
86
" <soap:Body soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n" +
87
" <mrns0:getTemp>\n" +
88
" <zipcode xsi:type=\"xs:string\">30106</zipcode>\n" +
89
" </mrns0:getTemp>\n" +
93
Map metadata = new HashMap();
94
metadata.put(Client.RAW, Boolean.TRUE);
95
metadata.put("TYPE", "POST");
97
Properties headerProps = new Properties();
98
headerProps.put("SOAPAction", "");
99
headerProps.put("Content-type", "text/xml; charset=UTF-8");
101
metadata.put("HEADER", headerProps);
104
HTTPUnMarshallerMetadataTestCase_Retired client = new HTTPUnMarshallerMetadataTestCase_Retired();
106
HTTPUnMarshallerMock unmarshaller = new HTTPUnMarshallerMock();
108
String result = client.makeInvocationCall(testURL, xml, metadata, unmarshaller);
110
// expect to get the following header
111
assertNotNull(unmarshaller.getMetadata());
112
List header = (List) unmarshaller.getMetadata().get("Status");
113
assertEquals("200", header.get(0));
115
// don't need to comapre full string. (as actual temp value will change each time run)
116
assertEquals(getExpectedWeatherResult().substring(0, 380), result.substring(0, 380));
120
private String getExpectedWeatherResult()
122
return "<?xml version='1.0' encoding='UTF-8'?>" +
123
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
125
"<ns1:getTempResponse xmlns:ns1=\"urn:xmethods-Temperature\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" +
126
"<return xsi:type=\"xsd:float\">60.0</return>" +
127
"</ns1:getTempResponse>" +
129
"</SOAP-ENV:Body>\n" +
130
"</SOAP-ENV:Envelope>";
b'\\ No newline at end of file'