シナリオ
.NET (WCF) で Web サービスを作成しましたが、クライアント アプリには Java Swing を使用する必要があります。
環境
ネットビーンズ 7.2
ジャバコード:
BookingService service;
List<Booking> bookings;
/**
* Creates new form Home
*/
public Home() {
initComponents();
service = new BookingService();
refresh();
}
private void refresh() {
DefaultTableModel model = (DefaultTableModel)grid.getModel();
model.setRowCount(0);
bookings = getAll().getBooking(); // breaks at this line
if (bookings != null && !bookings.isEmpty()) {
grid.getColumnModel().getColumn(0).setMinWidth(50);
grid.getColumnModel().getColumn(0).setMaxWidth(50);
grid.getColumnModel().getColumn(1).setMinWidth(150);
grid.getColumnModel().getColumn(1).setMaxWidth(150);
for (int i = 0; i < bookings.size(); i++) {
Booking item = bookings.get(i);
Object[] rowData = new Object[] {
item.getId(),
item.getCustomerId(),
item.getActivityId(),
item.getBookingDate(),
item.getStartTime(),
item.getEndTime()
};
model.addRow(rowData);
}
}
}
//etc
private static ArrayOfBooking getAll() {
racquetandhealthclient.services.bookings.BookingService service = new racquetandhealthclient.services.bookings.BookingService();
racquetandhealthclient.services.bookings.IBookingService port = service.getWSHttpBindingIBookingService();
return port.getAll();
}
出力:
ant -f C:\\Users\\Matt\\Documents\\NetBeansProjects\\RacquetAndHealthClient -Ddebug.class=racquetandhealthclient.Program debug
init:
Deleting: C:\Users\Matt\Documents\NetBeansProjects\RacquetAndHealthClient\build\built-jar.properties
deps-jar:
Updating property file: C:\Users\Matt\Documents\NetBeansProjects\RacquetAndHealthClient\build\built-jar.properties
wsimport-init:
wsimport-client-activities:
files are up to date
wsimport-client-bookings:
files are up to date
wsimport-client-charge-accounts:
files are up to date
wsimport-client-countries:
files are up to date
wsimport-client-customers:
files are up to date
wsimport-client-invoices:
files are up to date
wsimport-client-generate:
compile:
Mar 01, 2013 9:42:56 AM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector] selectAlternatives
WARNING: WSP0075: Policy assertion "{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}SymmetricBinding" was evaluated as "UNKNOWN".
Mar 01, 2013 9:42:56 AM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector] selectAlternatives
WARNING: WSP0075: Policy assertion "{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}Trust10" was evaluated as "UNKNOWN".
Mar 01, 2013 9:42:56 AM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector] selectAlternatives
WARNING: WSP0075: Policy assertion "{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}Wss11" was evaluated as "UNKNOWN".
Mar 01, 2013 9:42:56 AM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector] selectAlternatives
WARNING: WSP0075: Policy assertion "{http://www.w3.org/2006/05/addressing/wsdl}UsingAddressing" was evaluated as "UNKNOWN".
//ETC.... same as above lines about 30 times... then:
Exception in thread "AWT-EventQueue-0" com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 400: Bad Request
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.checkStatusCode(HttpTransportPipe.java:278)
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.createResponsePacket(HttpTransportPipe.java:245)
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:203)
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:122)
at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:123)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:626)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:585)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:570)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:467)
at com.sun.xml.internal.ws.client.Stub.process(Stub.java:308)
at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:146)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:129)
at $Proxy31.getAll(Unknown Source)
at racquetandhealthclient.views.bookings.Home.getAll(Home.java:94)
at racquetandhealthclient.views.bookings.Home.refresh(Home.java:35)
at racquetandhealthclient.views.bookings.Home.<init>(Home.java:28)
at racquetandhealthclient.Program$1.run(Program.java:38)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
debug:
BUILD SUCCESSFUL (total time: 1 minute 26 seconds)
助けてください!私は Java の専門家ではないので、何が問題で、どのように修正すればよいかを簡単に理解できるようにしてください。私は周りを「グーグル」しましたが、これについてはあまり見つかりませんでした。何か案は?
編集: Soap UI でこれを取得しました。ただし、どのような種類の認証も設定していないため、解決策が何であるかはわかりません。
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action>
</s:Header>
<s:Body>
<s:Fault>
<s:Code>
<s:Value>s:Sender</s:Value>
<s:Subcode>
<s:Value xmlns:a="http://schemas.xmlsoap.org/ws/2005/02/sc">a:BadContextToken</s:Value>
</s:Subcode>
</s:Code>
<s:Reason>
<s:Text xml:lang="en-US">The message could not be processed. This is most likely because the action 'http://tempuri.org/IBookingService/GetAll' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.</s:Text>
</s:Reason>
</s:Fault>
</s:Body>
</s:Envelope>
編集2:
OK みんな..わかった..基本的には、WCF サービスを から に変更する必要がありwsHttpBinding
ましたbasicHttpBinding
。彼らは異なるバージョンの SOAP 仕様を使用しているようです。これが他の人に役立つことを願っています。後で回答として追加しますが、評判が10未満であるため、StackOverflowはさらに8時間自分の質問に回答することを許可しません. 誰かがこの投稿に賛成票を投じることができれば、すぐに回答を追加します. :-)