이 방법을 설명하는 튜토리얼 또는 예제 문서가 있습니까? HTTP 요청을 할 수있는 Drakma HTTP 클라이언트를 볼 수 있지만 실제로 SOAP WebService를 호출하는 방법을 실제로 이해하지 못합니다 (심지어 가능하다면). 모든 지침 정말 감사하겠습니다.Common Lisp에서 SOAP 웹 서비스를 사용하는 방법은 무엇입니까?
답변
일반적인 lisp cl-soap 용 비누 클라이언트가 있지만 구식 인 것 같습니다. HTTP는 HTTP를 통해 구현되므로 drakma를 사용하여 SOAP 서비스로 쉽게 호출 할 수 있습니다. 우리는 또한 사용합니다 :
clozure 일반적인 lisp 또는 당신처럼 구현 SBCL quicklisp cl-ppcre; 이식 가능한 정규식 librarie plump; 그것은이 내부에 두 개의 매개 변수를 전달 그들을주의 깊게
읽어
여기http://www.webservicex.net/New/Home/ServiceDetail/56 당신이 비누 서비스에 대한 원시 요청을 찾을 수 있습니다 XML 파서는
은의 여기 http://www.webservicex.net/New/ 쉽게 하나가 될 수에서 비누 서비스를 부르 자 xml body를 입력 한 다음 하나의 xml을 다시 보냅니다.
soap 서비스는 쉽게 받아 들일 수 있으며 XML을 보내고 XML을 수신하는 HTTP 게시 메소드는 drakma를 사용하여 호출을 구성합니다.
는 SOAP 서비스의 중요한 파일은 WSDL 인 서비스의 설명입니다
http://www.webservicex.net/globalweather.asmx?WSDL
가의 리스프와 놀자 :
;; preparing the xml soap
(defun create-body-for-request-get-weather-soap (city-name country-name)
(format nil "~{~A~%~}" (list
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
"<soap:Body>"
"<GetWeather xmlns=\"http://www.webserviceX.NET\">"
(format nil "<CityName>~A</CityName>" city-name)
(format nil "<CountryName>~A</CountryName>" country-name)
"</GetWeather>"
"</soap:Body>"
"</soap:Envelope>")))
(defun send-soap-request (&key url soap-action soap-body)
(let* ((response
(drakma:http-request url
:method :post
:content-length t
:content-type "text/xml; charset=utf-8"
:additional-headers `(("SOAPAction" . ,soap-action))
:content soap-body)))
response))
(defparameter answer (send-soap-request
:url "http://www.webservicex.net/globalweather.asmx"
:soap-action "http://www.webserviceX.NET/GetWeather"
:soap-body (create-body-for-request-get-weather-soap "Valencia" "Spain")))
;;preparing the xml soap 1.2
(defun create-body-for-request-get-weather-soap12 (city-name country-name)
(format nil "~{~A~%~}"
(list "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">"
"<soap12:Body>"
"<GetWeather xmlns=\"http://www.webserviceX.NET\">"
(format nil "<CityName>~A</CityName>" city-name)
(format nil "<CountryName>~A</CountryName>" country-name)
"</GetWeather>"
"</soap12:Body>"
"</soap12:Envelope>")))
(defun send-soap12-request (&key url soap-action soap-body)
(let* ((response
(drakma:http-request url
:method :post
:content-length t
:content-type "application/soap+xml; charset=utf-8"
:additional-headers `(("SOAPAction" . ,soap-action))
:content soap-body)))
response))
;; the call
(defparameter answer (send-soap12-request
:url "http://www.webservicex.net/globalweather.asmx"
:soap-action "http://www.webserviceX.NET/GetWeather"
:soap-body (create-body-for-request-get-weather-soap12 "Valencia" "Spain")))
(class-of answer) ;; I do not know if I have an error with the codification, but in this case seems
;;and error with utf-8 and utf-16, so it returns and array of unsignet bytes it seems ascii so I convert it with common lisp
(format nil "~{~A~}" (map 'list #'(lambda (value) (code-char value)) answer))
및 답변 :
; 응답 옥텟에 대한 값
CL-USER>
; No value; compiling (DEFUN CREATE-BODY-FOR-REQUEST-GET-WEATHER-SOAP ...)
; compiling (DEFUN SEND-SOAP-REQUEST ...)
CL-USER> answer
"<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><GetWeatherResponse xmlns=\"http://www.webserviceX.NET\"><GetWeatherResult><?xml version=\"1.0\" encoding=\"utf-16\"?>
<CurrentWeather>
<Location>Valencia/Aeropuerto, Spain (LEVC) 39-30N 000-28W 62M</Location>
<Time>Jun 07, 2016 - 06:30 AM EDT/2016.06.07 1030 UTC</Time>
<Wind> from the E (080 degrees) at 9 MPH (8 KT) (direction variable):0</Wind>
<Visibility> greater than 7 mile(s):0</Visibility>
<SkyConditions> mostly clear</SkyConditions>
<Temperature> 78 F (26 C)</Temperature>
<DewPoint> 57 F (14 C)</DewPoint>
<RelativeHumidity> 47%</RelativeHumidity>
<Pressure> 30.18 in. Hg (1022 hPa)</Pressure>
<Status>Success</Status>
</CurrentWeather></GetWeatherResult></GetWeatherResponse></soap:Body></soap:Envelope>"
; compiling (DEFUN CREATE-BODY-FOR-REQUEST-GET-WEATHER-SOAP12 ...)
; compiling (DEFUN SEND-SOAP12-REQUEST ...)
CL-USER> answer
#(60 63 120 109 108 32 118 101 114 115 105 111 110 61 34 49 46 48 34 32 101 110
99 111 100 105 110 103 61 34 117 116 102 45 56 34 63 62 60 115 111 97 112 58
69 110 118 101 108 111 112 101 32 120 109 108 110 115 58 115 111 97 112 61 34
104 116 116 112 58 47 47 119 119 119 46 119 51 46 111 114 103 47 50 48 48 51
47 48 53 47 115 111 97 112 45 101 110 118 101 108 111 112 101 34 32 120 109
108 110 115 58 120 115 105 61 34 104 116 116 112 58 47 47 119 119 119 46 119
51 46 111 114 103 47 50 48 48 49 47 88 77 76 83 99 104 101 109 97 45 105 110
115 116 97 110 99 101 34 32 120 109 108 110 115 58 120 115 100 61 34 104 116
116 112 58 47 47 119 119 119 46 119 51 46 111 114 103 47 50 48 48 49 47 88 77
76 83 99 104 101 109 97 34 62 60 115 111 97 112 58 66 111 100 121 62 60 71
101 116 87 101 97 116 104 101 114 82 101 115 112 111 110 115 101 32 120 109
108 110 115 61 34 104 116 116 112 58 47 47 119 119 119 46 119 101 98 115 101
114 118 105 99 101 88 46 78 69 84 34 62 60 71 101 116 87 101 97 116 104 101
114 82 101 115 117 108 116 62 38 108 116 59 63 120 109 108 32 118 101 114 115
105 111 110 61 34 49 46 48 34 32 101 110 99 111 100 105 110 103 61 34 117 116
102 45 49 54 34 63 38 103 116 59 13 10 38 108 116 59 67 117 114 114 101 110
116 87 101 97 116 104 101 114 38 103 116 59 13 10 32 32 38 108 116 59 76 111
99 97 116 105 111 110 38 103 116 59 86 97 108 101 110 99 105 97 32 47 32 65
101 114 111 112 117 101 114 116 111 44 32 83 112 97 105 110 32 40 76 69 86 67
41 32 51 57 45 51 48 78 32 48 48 48 45 50 56 87 32 54 50 77 38 108 116 59 47
76 111 99 97 116 105 111 110 38 103 116 59 13 10 32 32 38 108 116 59 84 105
109 101 38 103 116 59 74 117 110 32 48 55 44 32 50 48 49 54 32 45 32 48 54 58
51 48 32 65 77 32 69 68 84 32 47 32 50 48 49 54 46 48 54 46 48 55 32 49 48 51
48 32 85 84 67 38 108 116 59 47 84 105 109 101 38 103 116 59 13 10 32 32 38
108 116 59 87 105 110 100 38 103 116 59 32 102 114 111 109 32 116 104 101 32
69 32 40 48 56 48 32 100 101 103 114 101 101 115 41 32 97 116 32 57 32 77 80
72 32 40 56 32 75 84 41 32 40 100 105 114 101 99 116 105 111 110 32 118 97
114 105 97 98 108 101 41 58 48 38 108 116 59 47 87 105 110 100 38 103 116 59
13 10 32 32 38 108 116 59 86 105 115 105 98 105 108 105 116 121 38 103 116 59
32 103 114 101 97 116 101 114 32 116 104 97 110 32 55 32 109 105 108 101 40
115 41 58 48 38 108 116 59 47 86 105 115 105 98 105 108 105 116 121 38 103
116 59 13 10 32 32 38 108 116 59 83 107 121 67 111 110 100 105 116 105 111
110 115 38 103 116 59 32 109 111 115 116 108 121 32 99 108 101 97 114 38 108
116 59 47 83 107 121 67 111 110 100 105 116 105 111 110 115 38 103 116 59 13
10 32 32 38 108 116 59 84 101 109 112 101 114 97 116 117 114 101 38 103 116
59 32 55 56 32 70 32 40 50 54 32 67 41 38 108 116 59 47 84 101 109 112 101
114 97 116 117 114 101 38 103 116 59 13 10 32 32 38 108 116 59 68 101 119 80
111 105 110 116 38 103 116 59 32 53 55 32 70 32 40 49 52 32 67 41 38 108 116
59 47 68 101 119 80 111 105 110 116 38 103 116 59 13 10 32 32 38 108 116 59
82 101 108 97 116 105 118 101 72 117 109 105 100 105 116 121 38 103 116 59 32
52 55 37 38 108 116 59 47 82 101 108 97 116 105 118 101 72 117 109 105 100
105 116 121 38 103 116 59 13 10 32 32 38 108 116 59 80 114 101 115 115 117
114 101 38 103 116 59 32 51 48 46 49 56 32 105 110 46 32 72 103 32 40 49 48
50 50 32 104 80 97 41 38 108 116 59 47 80 114 101 115 115 117 114 101 38 103
116 59 13 10 32 32 38 108 116 59 83 116 97 116 117 115 38 103 116 59 83 117
99 99 101 115 115 38 108 116 59 47 83 116 97 116 117 115 38 103 116 59 13 10
38 108 116 59 47 67 117 114 114 101 110 116 87 101 97 116 104 101 114 38 103
116 59 60 47 71 101 116 87 101 97 116 104 101 114 82 101 115 117 108 116 62
60 47 71 101 116 87 101 97 116 104 101 114 82 101 115 112 111 110 115 101 62
60 47 115 111 97 112 58 66 111 100 121 62 60 47 115 111 97 112 58 69 110 118
101 108 111 112 101 62)
CL-USER> (format nil "~{~A~}" (map 'list #'(lambda (value) (code-char value)) answer))
"<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><GetWeatherResponse xmlns=\"http://www.webserviceX.NET\"><GetWeatherResult><?xml version=\"1.0\" encoding=\"utf-16\"?>
<CurrentWeather>
<Location>Valencia/Aeropuerto, Spain (LEVC) 39-30N 000-28W 62M</Location>
<Time>Jun 07, 2016 - 06:30 AM EDT/2016.06.07 1030 UTC</Time>
<Wind> from the E (080 degrees) at 9 MPH (8 KT) (direction variable):0</Wind>
<Visibility> greater than 7 mile(s):0</Visibility>
<SkyConditions> mostly clear</SkyConditions>
<Temperature> 78 F (26 C)</Temperature>
<DewPoint> 57 F (14 C)</DewPoint>
<RelativeHumidity> 47%</RelativeHumidity>
<Pressure> 30.18 in. Hg (1022 hPa)</Pressure>
<Status>Success</Status>
</CurrentWeather></GetWeatherResult></GetWeatherResponse></soap:Body></soap:Envelope>"
CL-USER>
이것은 환상적인 설명이었고, 나를 위해 약간의 재료를 정말로 정리했다! 나는 SOAP을 단순화하는 방법을 특히 좋아했다. (HTTP를 보내고 돌려주는 POST 메서드). 단지 후속 조치로 byte-stream이 ascii라고 추측 했습니까? 어떻게 변환했는지 어떻게 알았습니까? – ajivani
음, 아마도이 단순화는 약간 과장되어 있지만 작동합니다. 두 번째 질문에서, 그것은 직감의 문제였습니다. 나는 배열의 부호없는 문자 클래스를 사용하므로 보통 ASCII 문자를 의미하지만 Base 10에 있으므로 기본 16 진수로 전달한 다음 문자로 변환합니다. 그러나 이것은 api, 또는 사용 된 charset 이게 도움이 된 것을 기쁘게 생각합니다 – anquegi
를 사용하여 UTF-8 인코딩 없습니다 :
(ppcre:regex-replace-all (format nil "~c" #\Return) (flexi-streams:octets-to-string response :external-format :utf-8) "")))
솔루션에서 대체 할 라인이 흥미 롭습니다. 끝 부분에 가까운이 하나가 변환되는 곳이 좋습니까? 여기에 하나 : "(형식 nil"~ {~ A ~} "(지도 '목록 #'(람다 (값) (코드 - char 값)))) 또는 다른 곳으로 변경 하시겠습니까? – ajivani
- 1. Common Lisp에서 실행중인 함수를 바꾸는 방법은 무엇입니까?
- 2. Common Lisp에서 쉼표 쉼표를 해석하는 방법은 무엇입니까?
- 3. PHP SOAP 웹 서비스를 소비하는 방법은 무엇입니까?
- 4. Common Lisp에서 라이브러리를로드하려면 어떻게해야합니까?
- 5. Common Lisp에서 함수의 범위
- 6. Common Lisp에서 타입 삭제하기
- 7. Java에서 SOAP 웹 서비스를 사용하는 가장 고통스러운 방법은 무엇입니까
- 8. Firefox OS에서 SOAP 웹 서비스를 사용하는 방법은 무엇입니까?
- 9. Mule Flow에서 SOAP 웹 서비스를 사용하는 방법은 무엇입니까?
- 10. Jquery 모바일에서 SOAP 웹 서비스를 사용하는 방법은 무엇입니까?
- 11. SAP UI5에서 SOAP 웹 서비스를 사용하는 방법은 무엇입니까?
- 12. 사용자 인터페이스에서 SOAP 웹 서비스를 사용하는 방법은 무엇입니까?
- 13. Typo3에서 웹 서비스를 사용하는 방법은 무엇입니까?
- 14. Common Lisp에서 HTML 테이블 스크랩하기?
- 15. Common Lisp에서 키워드는 어떻게 작동합니까?
- 16. Common Lisp에서 문자열과 숫자의 핵심 차이점은 무엇입니까?
- 17. Common Lisp에서 인쇄 된 표현이란 무엇입니까?
- 18. SOAP 웹 서비스를 ADFS2.0과 함께 사용하는 방법
- 19. Alfresco에서 SOAP 기반 웹 서비스를 사용하는 방법
- 20. VB6에서 SOAP 웹 서비스를 사용하는 방법?
- 21. Common Lisp에서 lambda의 이름 바꾸기
- 22. Common Lisp에서 경고를 캡처하고 계속하지만
- 23. | 5E | Common Lisp에서 의미가 있습니까?
- 24. Common Lisp에서 독자 매크로 관리
- 25. Mandelbrot Common Lisp에서 구현 설정
- 26. funcall은 Common Lisp에서 어떻게 작동합니까?
- 27. Common Lisp에서 퀴즈를 생성 하시겠습니까?
- 28. Common Lisp에서 문자열에 문자 추가
- 29. Common Lisp에서 SQLite의 오류 잡기
- 30. 클라이언트에서 웹 서비스를 사용하는 방법은 무엇입니까?
[리스프 비누 클라이언트 (의 가능한 중복 http://stackoverflow.com/questions/1396652/lisp-soap- 클라이언트) – lifeisfoo