2010-02-25 3 views
1

PHP soapclient 요청에 값으로 배열을 전달할 수 있습니까?PHP soapclient 요청에 값으로 배열을 전달할 수 있습니까?

이미 soapclient가 인스턴스화되어 연결되어 있습니다. 그런 다음 3 매개 변수 (문자열, 문자열, 해시 맵) 기대하는 webservice 메서드에 대한 호출을 시도합니다.

다음은 내가 아래에서 작업 할 것으로 예상 한 것입니다. 그러나 xml 출력을 볼 때 params 노드는 비어 있습니다.

soapclient->doSomething(array('id' => 'blah', 'page' => 'blah', 'params' => array('email' => '[email protected]', 'password' => 'password', 'blah' => 'blah'))); 

비누 바디 XML은 (빈 PARAMS 요소에주의)과 같이 끝 :

<SOAP-ENV:Body><ns1:doSomething> 
<id>blah</id> 
<page>blah</page> 
<params/> 
</ns1:register></SOAP-ENV:Body> 

답변

0

WebService에 정의에 따라, 해시 맵 매개 변수는 할 수있는 특정 구조/인코딩을해야 할 수도 있습니다 배열에서 직접 생성되지 않습니다. 여기에서 WSDL을 확인하고 비누 매개 변수 구성에 대한 추가 옵션을 보려면 SoapVarSoapParam 클래스를 살펴볼 수 있습니다.

2

JAX-WS 웹 서비스의 경우 hashmap 입력 매개 변수에 문제가있을 수 있습니다. 생성 된 xsd 스키마가 해시 맵에 대해 올바르지 않은 것 같습니다. 맵을 랩퍼 오브젝트에두면 JAX-WS가 올 Y 른 xsd를 출력합니다.

public class MapWrapper { 
    public HashMap<String, String> map; 
} 


// in your web service class 
@WebMethod(operationName = "doSomething") 
public SomeResponseObject doSomething(
     @WebParam(name = "id") String id, 
     @WebParam(name = "page") String page, 
     @WebParam(name = "params") MapWrapper params { 
    // body of method 
} 

그러면 PHP 코드가 성공합니다. SoapVar 또는 SoapParam이 필요하지 않으며 MapWrapper없이 작동 할 수있는 메서드 중 하나를 얻을 수 없다는 것을 알았습니다.

$entry1['key'] = 'somekey'; 
$entry1['value'] = 1; 
$params['map'] = array($entry1); 
soapclient->doSomething(array('id' => 'blah', 'page' => 'blah', 
    'params' => $params)); 

여기 여기에 단지 해시 맵

<xs:complexType name="hashMap"> 
    <xs:complexContent> 
    <xs:extension base="tns:abstractMap"> 
     <xs:sequence/> 
    </xs:extension> 
    </xs:complexContent> 
</xs:complexType> 
<xs:complexType name="abstractMap" abstract="true"> 
    <xs:sequence/> 
</xs:complexType> 

마지막 메모와 함께 JAX-WS에 의해 생성 된 잘못된 스키마는 래퍼

<xs:complexType name="mapWrapper"> 
    <xs:sequence> 
    <xs:element name="map"> 
     <xs:complexType> 
     <xs:sequence> 
      <xs:element name="entry" minOccurs="0" maxOccurs="unbounded"> 
      <xs:complexType> 
       <xs:sequence> 
       <xs:element name="key" minOccurs="0" type="xs:string"/> 
       <xs:element name="value" minOccurs="0" type="xs:string"/> 
       </xs:sequence> 
      </xs:complexType> 
      </xs:element> 
     </xs:sequence> 
     </xs:complexType> 
    </xs:element> 
    </xs:sequence> 
</xs:complexType> 

생성 올바른 XSD입니다. 줄 바꿈 HashMap < 문자열, 문자열 >이 솔루션과 함께 작동하지만 HashMap < 문자열, 개체 >하지 않았습니다. Object는 xsd : anyType에 매핑되며 Java WebService에는 Object가 아닌 xsd 스키마 객체로 제공됩니다.

관련 문제